/[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.7 by miles, Wed Oct 6 05:21:52 2004 UTC revision 1.47.2.8 by miles, Wed Oct 6 05:23:55 2004 UTC
# Line 1  Line 1 
1  ;;; term.el --- general command interpreter in a window stuff  ;;; term.el --- general command interpreter in a window stuff
2    
3  ;;; Copyright (C) 1988, 1990, 1992, 1994, 1995 Free Software Foundation, Inc.  ;;; Copyright (C) 1988, 1990, 1992, 1994, 1995, 2004 Free Software Foundation, Inc.
4    
5  ;; Author: Per Bothner <bothner@cygnus.com>  ;; Author: Per Bothner <bothner@cygnus.com>
6  ;; Based on comint mode written by: Olin Shivers <shivers@cs.cmu.edu>  ;; Based on comint mode written by: Olin Shivers <shivers@cs.cmu.edu>
# Line 676  Buffer local variable.") Line 676  Buffer local variable.")
676  (defvar term-terminal-menu)  (defvar term-terminal-menu)
677    
678  ;;; Let's silence the byte-compiler -mm  ;;; Let's silence the byte-compiler -mm
 (defvar term-ansi-at-eval-string nil)  
679  (defvar term-ansi-at-host nil)  (defvar term-ansi-at-host nil)
680  (defvar term-ansi-at-dir nil)  (defvar term-ansi-at-dir nil)
681  (defvar term-ansi-at-user nil)  (defvar term-ansi-at-user nil)
# Line 692  Buffer local variable.") Line 691  Buffer local variable.")
691  (defvar term-ansi-current-highlight 0)  (defvar term-ansi-current-highlight 0)
692  (defvar term-ansi-current-reverse 0)  (defvar term-ansi-current-reverse 0)
693  (defvar term-ansi-current-invisible 0)  (defvar term-ansi-current-invisible 0)
 (defvar term-ansi-default-fg 0)  
 (defvar term-ansi-default-bg 0)  
 (defvar term-ansi-current-temp 0)  
694    
695  ;;; Four should be enough, if you want more, just add. -mm  ;;; Four should be enough, if you want more, just add. -mm
696  (defvar term-terminal-more-parameters 0)  (defvar term-terminal-more-parameters 0)
# Line 917  is buffer-local.") Line 913  is buffer-local.")
913      (define-key term-raw-map [backspace] 'term-send-backspace)      (define-key term-raw-map [backspace] 'term-send-backspace)
914      (define-key term-raw-map [home] 'term-send-home)      (define-key term-raw-map [home] 'term-send-home)
915      (define-key term-raw-map [end] 'term-send-end)      (define-key term-raw-map [end] 'term-send-end)
916        (define-key term-raw-map [S-prior] 'scroll-down)
917        (define-key term-raw-map [S-next] 'scroll-up)
918        (define-key term-raw-map [S-insert] 'term-paste)
919      (define-key term-raw-map [prior] 'term-send-prior)      (define-key term-raw-map [prior] 'term-send-prior)
920      (define-key term-raw-map [next] 'term-send-next)))      (define-key term-raw-map [next] 'term-send-next)))
921    
# Line 932  is buffer-local.") Line 931  is buffer-local.")
931    
932  (put 'term-mode 'mode-class 'special)  (put 'term-mode 'mode-class 'special)
933    
934    
935    ;;; Use this variable as a display table for `term-mode'.
936    (defvar term-display-table
937      (let ((dt (or (copy-sequence standard-display-table)
938                    (make-display-table)))
939            i)
940        ;; avoid changing the display table for ^J
941        (setq i 0)
942        (while (< i 10)
943          (aset dt i (vector i))
944          (setq i (1+ i)))
945        (setq i 11)
946        (while (< i 32)
947          (aset dt i (vector i))
948          (setq i (1+ i)))
949        (setq i 128)
950        (while (< i 256)
951          (aset dt i (vector i))
952          (setq i (1+ i)))
953        dt))
954    
955  (defun term-mode ()  (defun term-mode ()
956    "Major mode for interacting with an inferior interpreter.    "Major mode for interacting with an inferior interpreter.
957  The interpreter name is same as buffer name, sans the asterisks.  The interpreter name is same as buffer name, sans the asterisks.
# Line 981  Entry to this mode runs the hooks on `te Line 1001  Entry to this mode runs the hooks on `te
1001    (setq major-mode 'term-mode)    (setq major-mode 'term-mode)
1002    (setq mode-name "Term")    (setq mode-name "Term")
1003    (use-local-map term-mode-map)    (use-local-map term-mode-map)
1004      ;; we do not want indent to sneak in any tabs
1005      (setq indent-tabs-mode nil)
1006      (setq buffer-display-table term-display-table)
1007    (make-local-variable 'term-home-marker)    (make-local-variable 'term-home-marker)
1008    (setq term-home-marker (copy-marker 0))    (setq term-home-marker (copy-marker 0))
1009    (make-local-variable 'term-saved-home-marker)    (make-local-variable 'term-saved-home-marker)
# Line 1184  without any interpretation." Line 1207  without any interpretation."
1207                                          ((eq arg '-) -1)                                          ((eq arg '-) -1)
1208                                          (t (1- arg)))))))                                          (t (1- arg)))))))
1209    
1210    (defun term-paste ()
1211      "Insert the last stretch of killed text at point."
1212      (interactive)
1213       (term-send-raw-string (current-kill 0)))
1214    
1215  ;; Which would be better:  "\e[A" or "\eOA"? readline accepts either.  ;; Which would be better:  "\e[A" or "\eOA"? readline accepts either.
1216  ;; For my configuration it's definitely better \eOA but YMMV. -mm  ;; For my configuration it's definitely better \eOA but YMMV. -mm
1217  ;; For example: vi works with \eOA while elm wants \e[A ...  ;; For example: vi works with \eOA while elm wants \e[A ...
# Line 1195  without any interpretation." Line 1223  without any interpretation."
1223  (defun term-send-end   () (interactive) (term-send-raw-string "\e[4~"))  (defun term-send-end   () (interactive) (term-send-raw-string "\e[4~"))
1224  (defun term-send-prior () (interactive) (term-send-raw-string "\e[5~"))  (defun term-send-prior () (interactive) (term-send-raw-string "\e[5~"))
1225  (defun term-send-next  () (interactive) (term-send-raw-string "\e[6~"))  (defun term-send-next  () (interactive) (term-send-raw-string "\e[6~"))
1226  (defun term-send-del   () (interactive) (term-send-raw-string "\C-?"))  (defun term-send-del   () (interactive) (term-send-raw-string "\e[3~"))
1227  (defun term-send-backspace  () (interactive) (term-send-raw-string "\C-H"))  (defun term-send-backspace  () (interactive) (term-send-raw-string "\C-?"))
1228    
1229  (defun term-char-mode ()  (defun term-char-mode ()
1230    "Switch to char (\"raw\") sub-mode of term mode.    "Switch to char (\"raw\") sub-mode of term mode.
# Line 1366  The main purpose is to get rid of the lo Line 1394  The main purpose is to get rid of the lo
1394    "%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\
1395  :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\
1396  :al=\\E[L:dl=\\E[M:DL=\\E[%%dM:AL=\\E[%%dL:cs=\\E[%%i%%d;%%dr:sf=^J\  :al=\\E[L:dl=\\E[M:DL=\\E[%%dM:AL=\\E[%%dL:cs=\\E[%%i%%d;%%dr:sf=^J\
 :te=\\E[2J\\E[?47l\\E8:ti=\\E7\\E[?47h\  
1397  :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:\
1398  :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\
1399  :UP=\\E[%%dA:DO=\\E[%%dB:LE=\\E[%%dD:RI=\\E[%%dC\  :UP=\\E[%%dA:DO=\\E[%%dB:LE=\\E[%%dD:RI=\\E[%%dC\
1400  :kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E[5~:@7=\\E[4~:kh=\\E[1~\  :kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E[5~:@7=\\E[4~:kh=\\E[1~\
1401  :mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#8:pa#64:AB=\\E[4%%dm:AF=\\E[3%%dm:cr=^M\  :mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#8:pa#64:AB=\\E[4%%dm:AF=\\E[3%%dm:cr=^M\
1402  :bl=^G:do=^J:le=^H:ta=^I:se=\E[27m:ue=\E24m:"  :bl=^G:do=^J:le=^H:ta=^I:se=\E[27m:ue=\E24m\
1403    :kb=^?:kD=^[[3~:sc=\E7:rc=\E8:"
1404  ;;; : -undefine ic  ;;; : -undefine ic
1405    ;;; don't define :te=\\E[2J\\E[?47l\\E8:ti=\\E7\\E[?47h\
1406    "termcap capabilities supported")    "termcap capabilities supported")
1407    
1408  ;;; This auxiliary function cranks up the process for term-exec in  ;;; This auxiliary function cranks up the process for term-exec in
# Line 1400  The main purpose is to get rid of the lo Line 1429  The main purpose is to get rid of the lo
1429          (process-connection-type t)          (process-connection-type t)
1430          ;; We should suppress conversion of end-of-line format.          ;; We should suppress conversion of end-of-line format.
1431          (inhibit-eol-conversion t)          (inhibit-eol-conversion t)
1432          ;; inhibit-eol-conversion doesn't seem to do the job, but this does.          ;; The process's output contains not just chars but also binary
1433          (coding-system-for-read 'unknown-unix)          ;; escape codes, so we need to see the raw output.  We will have to
1434          )          ;; do the decoding by hand on the parts that are made of chars.
1435            (coding-system-for-read 'binary))
1436      (apply 'start-process name buffer      (apply 'start-process name buffer
1437             "/bin/sh" "-c"             "/bin/sh" "-c"
1438             (format "stty -nl echo rows %d columns %d sane 2>/dev/null;\             (format "stty -nl echo rows %d columns %d sane 2>/dev/null;\
# Line 2558  See `term-prompt-regexp'." Line 2588  See `term-prompt-regexp'."
2588                     (- (term-vertical-motion -9999))))))))                     (- (term-vertical-motion -9999))))))))
2589    
2590  (defun term-adjust-current-row-cache (delta)  (defun term-adjust-current-row-cache (delta)
2591    (if term-current-row    (when term-current-row
2592        (setq term-current-row (+ term-current-row delta))))      (setq term-current-row
2593              (max 0 (+ term-current-row delta)))))
2594    
2595  (defun term-terminal-pos ()  (defun term-terminal-pos ()
2596    (save-excursion ;    save-restriction    (save-excursion ;    save-restriction
# Line 2693  See `term-prompt-regexp'." Line 2724  See `term-prompt-regexp'."
2724                     (if (not funny) (setq funny str-length))                     (if (not funny) (setq funny str-length))
2725                     (cond ((> funny i)                     (cond ((> funny i)
2726                            (cond ((eq term-terminal-state 1)                            (cond ((eq term-terminal-state 1)
2727                                   (term-move-columns 1)                                   ;; We are in state 1, we need to wrap
2728                                     ;; around.  Go to the beginning of
2729                                     ;; the next line and switch to state
2730                                     ;; 0.
2731                                     (term-down 1)
2732                                     (term-move-columns (- (term-current-column)))
2733                                   (setq term-terminal-state 0)))                                   (setq term-terminal-state 0)))
2734                            (setq count (- funny i))                            (setq count (- funny i))
2735                            (setq temp (- (+ (term-horizontal-column) count)                            (setq temp (- (+ (term-horizontal-column) count)
# Line 2702  See `term-prompt-regexp'." Line 2738  See `term-prompt-regexp'."
2738                                  ((> count temp) ;; Some chars fit.                                  ((> count temp) ;; Some chars fit.
2739                                   ;; This iteration, handle only what fits.                                   ;; This iteration, handle only what fits.
2740                                   (setq count (- count temp))                                   (setq count (- count temp))
2741                                     (setq temp 0)
2742                                   (setq funny (+ count i)))                                   (setq funny (+ count i)))
2743                                  ((or (not (or term-pager-count                                  ((or (not (or term-pager-count
2744                                                term-scroll-with-delete))                                                term-scroll-with-delete))
# Line 2722  See `term-prompt-regexp'." Line 2759  See `term-prompt-regexp'."
2759                            ;; following point if not eob nor insert-mode.                            ;; following point if not eob nor insert-mode.
2760                            (let ((old-column (current-column))                            (let ((old-column (current-column))
2761                                  columns pos)                                  columns pos)
2762                              (insert (substring str i funny))                              (insert (decode-coding-string (substring str i funny) locale-coding-system))
2763                              (setq term-current-column (current-column)                              (setq term-current-column (current-column)
2764                                    columns (- term-current-column old-column))                                    columns (- term-current-column old-column))
2765                              (when (not (or (eobp) term-insert-mode))                              (when (not (or (eobp) term-insert-mode))
2766                                (setq pos (point))                                (setq pos (point))
2767                                (term-move-columns columns)                                (term-move-columns columns)
2768                                (delete-region pos (point))))                                (delete-region pos (point)))
2769                                ;; In insert if the if the current line
2770                                ;; has become too long it needs to be
2771                                ;; chopped off.
2772                                (when term-insert-mode
2773                                  (setq pos (point))
2774                                  (end-of-line)
2775                                  (when (> (current-column) term-width)
2776                                    (delete-region (- (point) (- (current-column) term-width))
2777                                                   (point)))
2778                                  (goto-char pos)))
2779                            (setq term-current-column nil)                            (setq term-current-column nil)
2780    
2781                            (put-text-property old-point (point)                            (put-text-property old-point (point)
# Line 2741  See `term-prompt-regexp'." Line 2788  See `term-prompt-regexp'."
2788                                   (setq term-terminal-state 1)))                                   (setq term-terminal-state 1)))
2789                            (setq i (1- funny)))                            (setq i (1- funny)))
2790                           ((and (setq term-terminal-state 0)                           ((and (setq term-terminal-state 0)
2791                                 (eq char ?\^I)) ; TAB                                 (eq char ?\^I)) ; TAB (terminfo: ht)
                           ;; FIXME:  Does not handle line wrap!  
2792                            (setq count (term-current-column))                            (setq count (term-current-column))
2793                            (setq count (+ count 8 (- (mod count 8))))                            ;; The line cannot exceed term-width. TAB at
2794                            (if (< (move-to-column count nil) count)                            ;; the end of a line should not cause wrapping.
2795                                (term-insert-char char 1))                            (setq count (min term-width
2796                            (setq term-current-column count))                                             (+ count 8 (- (mod count 8)))))
2797                              (if (> term-width count)
2798                                (progn
2799                                  (term-move-columns
2800                                   (- count (term-current-column)))
2801                                  (setq term-current-column count))
2802                                (when (> term-width (term-current-column))
2803                                  (term-move-columns
2804                                   (1- (- term-width (term-current-column)))))
2805                                (when (= term-width (term-current-column))
2806                                  (term-move-columns -1))))
2807                           ((eq char ?\r)                           ((eq char ?\r)
2808                            ;; Optimize CRLF at end of buffer:                            ;; Optimize CRLF at end of buffer:
2809                            (cond ((and (< (setq temp (1+ i)) str-length)                            (cond ((and (< (setq temp (1+ i)) str-length)
# Line 2768  See `term-prompt-regexp'." Line 2824  See `term-prompt-regexp'."
2824                            (if (not (and term-kill-echo-list                            (if (not (and term-kill-echo-list
2825                                          (term-check-kill-echo-list)))                                          (term-check-kill-echo-list)))
2826                                (term-down 1 t)))                                (term-down 1 t)))
2827                           ((eq char ?\b)                           ((eq char ?\b)  ;; (terminfo: cub1)
2828                            (term-move-columns -1))                            (term-move-columns -1))
2829                           ((eq char ?\033) ; Escape                           ((eq char ?\033) ; Escape
2830                            (setq term-terminal-state 2))                            (setq term-terminal-state 2))
# Line 2815  See `term-prompt-regexp'." Line 2871  See `term-prompt-regexp'."
2871                            (term-handle-deferred-scroll)                            (term-handle-deferred-scroll)
2872                            (term-down 1 t)                            (term-down 1 t)
2873                            (setq term-terminal-state 0))                            (setq term-terminal-state 0))
2874                           ((eq char ?M) ;; scroll reversed                           ;; ((eq char ?E) ;; (terminfo: nw), not used for
2875                            (term-insert-lines 1)                           ;;            ;; now, but this is a working
2876                             ;;            ;; implementation
2877                             ;;  (term-down 1)
2878                             ;;  (term-goto term-current-row 0)
2879                             ;;  (setq term-terminal-state 0))
2880                             ((eq char ?M) ;; scroll reversed (terminfo: ri)
2881                              (term-down -1)
2882                            (setq term-terminal-state 0))                            (setq term-terminal-state 0))
2883                           ((eq char ?7) ;; Save cursor                           ((eq char ?7) ;; Save cursor (terminfo: sc)
2884                            (term-handle-deferred-scroll)                            (term-handle-deferred-scroll)
2885                            (setq term-saved-cursor                            (setq term-saved-cursor
2886                                  (cons (term-current-row)                                  (cons (term-current-row)
2887                                        (term-horizontal-column)))                                        (term-horizontal-column)))
2888                            (setq term-terminal-state 0))                            (setq term-terminal-state 0))
2889                           ((eq char ?8) ;; Restore cursor                           ((eq char ?8) ;; Restore cursor (terminfo: rc)
2890                            (if term-saved-cursor                            (if term-saved-cursor
2891                                (term-goto (car term-saved-cursor)                                (term-goto (car term-saved-cursor)
2892                                           (cdr term-saved-cursor)))                                           (cdr term-saved-cursor)))
2893                            (setq term-terminal-state 0))                            (setq term-terminal-state 0))
2894                             ;; The \E#8 reset sequence for xterm. We
2895                             ;; probably don't need to handle it, but this
2896                             ;; is the code to parse it.
2897                             ;; ((eq char ?#)
2898                             ;;  (when (eq (aref str (1+ i)) ?8)
2899                             ;;    (setq i (1+ i))
2900                             ;;    (setq term-terminal-state 0)))
2901                           ((setq term-terminal-state 0))))                           ((setq term-terminal-state 0))))
2902                    ((eq term-terminal-state 3) ; Seen Esc [                    ((eq term-terminal-state 3) ; Seen Esc [
2903                     (cond ((and (>= char ?0) (<= char ?9))                     (cond ((and (>= char ?0) (<= char ?9))
# Line 2976  See `term-prompt-regexp'." Line 3045  See `term-prompt-regexp'."
3045     ((eq parameter 8)     ((eq parameter 8)
3046      (setq term-ansi-current-invisible 1))      (setq term-ansi-current-invisible 1))
3047    
3048  ;;; Reset reverse (i.e. terminfo rmso)  ;;; Reset underline (i.e. terminfo rmul)
3049     ((eq parameter 24)     ((eq parameter 24)
3050      (setq term-ansi-current-reverse 0))      (setq term-ansi-current-underline 0))
3051    
3052  ;;; Reset underline (i.e. terminfo rmul)  ;;; Reset reverse (i.e. terminfo rmso)
3053     ((eq parameter 27)     ((eq parameter 27)
3054      (setq term-ansi-current-underline 0))      (setq term-ansi-current-reverse 0))
3055    
3056  ;;; Foreground  ;;; Foreground
3057     ((and (>= parameter 30) (<= parameter 37))     ((and (>= parameter 30) (<= parameter 37))
# Line 3085  See `term-prompt-regexp'." Line 3154  See `term-prompt-regexp'."
3154    
3155  (defun term-handle-ansi-escape (proc char)  (defun term-handle-ansi-escape (proc char)
3156    (cond    (cond
3157     ((eq char ?H) ; cursor motion     ((or (eq char ?H)  ; cursor motion (terminfo: cup)
3158            ;; (eq char ?f) ; xterm seems to handle this sequence too, not
3159            ;; needed for now
3160            )
3161      (if (<= term-terminal-parameter 0)      (if (<= term-terminal-parameter 0)
3162          (setq term-terminal-parameter 1))          (setq term-terminal-parameter 1))
3163      (if (<= term-terminal-previous-parameter 0)      (if (<= term-terminal-previous-parameter 0)
# Line 3097  See `term-prompt-regexp'." Line 3169  See `term-prompt-regexp'."
3169      (term-goto      (term-goto
3170       (1- term-terminal-previous-parameter)       (1- term-terminal-previous-parameter)
3171       (1- term-terminal-parameter)))       (1- term-terminal-parameter)))
3172     ;; \E[A - cursor up     ;; \E[A - cursor up (terminfo: cuu, cuu1)
3173     ((eq char ?A)     ((eq char ?A)
3174      (term-handle-deferred-scroll)      (term-handle-deferred-scroll)
3175      (term-down (- (max 1 term-terminal-parameter)) t))      (term-down (- (max 1 term-terminal-parameter)) t))
3176     ;; \E[B - cursor down     ;; \E[B - cursor down (terminfo: cud)
3177     ((eq char ?B)     ((eq char ?B)
3178      (term-down (max 1 term-terminal-parameter) t))      (term-down (max 1 term-terminal-parameter) t))
3179     ;; \E[C - cursor right     ;; \E[C - cursor right (terminfo: cuf)
3180     ((eq char ?C)     ((eq char ?C)
3181      (term-move-columns (max 1 term-terminal-parameter)))      (term-move-columns
3182     ;; \E[D - cursor left       (max 1
3183              (if (>= (+ term-terminal-parameter (term-current-column)) term-width)
3184                  (- term-width (term-current-column)  1)
3185                term-terminal-parameter))))
3186       ;; \E[D - cursor left (terminfo: cub)
3187     ((eq char ?D)     ((eq char ?D)
3188      (term-move-columns (- (max 1 term-terminal-parameter))))      (term-move-columns (- (max 1 term-terminal-parameter))))
3189     ;; \E[J - clear to end of screen     ;; \E[J - clear to end of screen (terminfo: ed, clear)
3190     ((eq char ?J)     ((eq char ?J)
3191      (term-erase-in-display term-terminal-parameter))      (term-erase-in-display term-terminal-parameter))
3192     ;; \E[K - clear to end of line     ;; \E[K - clear to end of line (terminfo: el, el1)
3193     ((eq char ?K)     ((eq char ?K)
3194      (term-erase-in-line term-terminal-parameter))      (term-erase-in-line term-terminal-parameter))
3195     ;; \E[L - insert lines     ;; \E[L - insert lines (terminfo: il, il1)
3196     ((eq char ?L)     ((eq char ?L)
3197      (term-insert-lines (max 1 term-terminal-parameter)))      (term-insert-lines (max 1 term-terminal-parameter)))
3198     ;; \E[M - delete lines     ;; \E[M - delete lines
# Line 3130  See `term-prompt-regexp'." Line 3206  See `term-prompt-regexp'."
3206      (term-insert-spaces (max 1 term-terminal-parameter)))      (term-insert-spaces (max 1 term-terminal-parameter)))
3207     ;; \E[?h - DEC Private Mode Set     ;; \E[?h - DEC Private Mode Set
3208     ((eq char ?h)     ((eq char ?h)
3209      (cond ((eq term-terminal-parameter 4)      (cond ((eq term-terminal-parameter 4)  ;; (terminfo: smir)
3210             (setq term-insert-mode t))             (setq term-insert-mode t))
3211            ((eq term-terminal-parameter 47)            ;; ((eq term-terminal-parameter 47) ;; (terminfo: smcup)
3212             (term-switch-to-alternate-sub-buffer t))))            ;; (term-switch-to-alternate-sub-buffer t))
3213              ))
3214     ;; \E[?l - DEC Private Mode Reset     ;; \E[?l - DEC Private Mode Reset
3215     ((eq char ?l)     ((eq char ?l)
3216      (cond ((eq term-terminal-parameter 4)      (cond ((eq term-terminal-parameter 4)  ;; (terminfo: rmir)
3217             (setq term-insert-mode nil))             (setq term-insert-mode nil))
3218            ((eq term-terminal-parameter 47)            ;; ((eq term-terminal-parameter 47) ;; (terminfo: rmcup)
3219             (term-switch-to-alternate-sub-buffer nil))))            ;; (term-switch-to-alternate-sub-buffer nil))
3220              ))
3221    
3222  ;;; Modified to allow ansi coloring -mm  ;;; Modified to allow ansi coloring -mm
3223     ;; \E[m - Set/reset standard mode     ;; \E[m - Set/reset modes, set bg/fg
3224       ;;(terminfo: smso,rmso,smul,rmul,rev,bold,sgr0,invis,op,setab,setaf)
3225     ((eq char ?m)     ((eq char ?m)
3226      (when (= term-terminal-more-parameters 1)      (when (= term-terminal-more-parameters 1)
3227        (if (>= term-terminal-previous-parameter-4 0)        (if (>= term-terminal-previous-parameter-4 0)
# Line 3162  See `term-prompt-regexp'." Line 3241  See `term-prompt-regexp'."
3241                                   (1+ (term-current-row))                                   (1+ (term-current-row))
3242                                   (1+ (term-horizontal-column)))))                                   (1+ (term-horizontal-column)))))
3243     ;; \E[r - Set scrolling region     ;; \E[r - Set scrolling region
3244     ((eq char ?r)     ((eq char ?r) ;; (terminfo: csr)
3245      (term-scroll-region      (term-scroll-region
3246       (1- term-terminal-previous-parameter)       (1- term-terminal-previous-parameter)
3247       term-terminal-parameter))       term-terminal-parameter))
# Line 3184  The top-most line is line 0." Line 3263  The top-most line is line 0."
3263    (setq term-scroll-with-delete    (setq term-scroll-with-delete
3264          (or (term-using-alternate-sub-buffer)          (or (term-using-alternate-sub-buffer)
3265              (not (and (= term-scroll-start 0)              (not (and (= term-scroll-start 0)
3266                        (= term-scroll-end term-height))))))                        (= term-scroll-end term-height)))))
3267      (term-move-columns (- (term-current-column)))
3268  (defun term-switch-to-alternate-sub-buffer (set)    (term-goto
3269    ;; If asked to switch to (from) the alternate sub-buffer, and already (not)     term-scroll-start (term-current-column)))
3270    ;; using it, do nothing.  This test is needed for some programs (including  
3271    ;; Emacs) that emit the ti termcap string twice, for unknown reason.  ;; (defun term-switch-to-alternate-sub-buffer (set)
3272    (term-handle-deferred-scroll)  ;;   ;; If asked to switch to (from) the alternate sub-buffer, and already (not)
3273    (if (eq set (not (term-using-alternate-sub-buffer)))  ;;   ;; using it, do nothing.  This test is needed for some programs (including
3274        (let ((row (term-current-row))  ;;   ;; Emacs) that emit the ti termcap string twice, for unknown reason.
3275              (col (term-horizontal-column)))  ;;   (term-handle-deferred-scroll)
3276          (cond (set  ;;   (if (eq set (not (term-using-alternate-sub-buffer)))
3277                 (goto-char (point-max))  ;;       (let ((row (term-current-row))
3278                 (if (not (eq (preceding-char) ?\n))  ;;          (col (term-horizontal-column)))
3279                     (term-insert-char ?\n 1))  ;;      (cond (set
3280                 (setq term-scroll-with-delete t)  ;;             (goto-char (point-max))
3281                 (setq term-saved-home-marker (copy-marker term-home-marker))  ;;             (if (not (eq (preceding-char) ?\n))
3282                 (set-marker term-home-marker (point)))  ;;                 (term-insert-char ?\n 1))
3283                (t  ;;             (setq term-scroll-with-delete t)
3284                 (setq term-scroll-with-delete  ;;             (setq term-saved-home-marker (copy-marker term-home-marker))
3285                       (not (and (= term-scroll-start 0)  ;;             (set-marker term-home-marker (point)))
3286                                 (= term-scroll-end term-height))))  ;;            (t
3287                 (set-marker term-home-marker term-saved-home-marker)  ;;             (setq term-scroll-with-delete
3288                 (set-marker term-saved-home-marker nil)  ;;                   (not (and (= term-scroll-start 0)
3289                 (setq term-saved-home-marker nil)  ;;                             (= term-scroll-end term-height))))
3290                 (goto-char term-home-marker)))  ;;             (set-marker term-home-marker term-saved-home-marker)
3291          (setq term-current-column nil)  ;;             (set-marker term-saved-home-marker nil)
3292          (setq term-current-row 0)  ;;             (setq term-saved-home-marker nil)
3293          (term-goto row col))))  ;;             (goto-char term-home-marker)))
3294    ;;      (setq term-current-column nil)
3295    ;;      (setq term-current-row 0)
3296    ;;      (term-goto row col))))
3297    
3298  ;; Default value for the symbol term-command-hook.  ;; Default value for the symbol term-command-hook.
3299    
# Line 3521  all pending output has been dealt with." Line 3603  all pending output has been dealt with."
3603    (if (not (bolp)) (insert-before-markers ?\n)))    (if (not (bolp)) (insert-before-markers ?\n)))
3604    
3605  (defun term-erase-in-line (kind)  (defun term-erase-in-line (kind)
3606    (if (> kind 1) ;; erase left of point    (if (= kind 1) ;; erase left of point
3607        (let ((cols (term-horizontal-column)) (saved-point (point)))        (let ((cols (term-horizontal-column)) (saved-point (point)))
3608          (term-vertical-motion 0)          (term-vertical-motion 0)
3609          (delete-region (point) saved-point)          (delete-region (point) saved-point)
3610          (term-insert-char ?\n cols)))          (term-insert-char ?  cols)))
3611    (if (not (eq kind 1)) ;; erase right of point    (if (not (eq kind 1)) ;; erase right of point
3612        (let ((saved-point (point))        (let ((saved-point (point))
3613              (wrapped (and (zerop (term-horizontal-column))              (wrapped (and (zerop (term-horizontal-column))
# Line 3562  Should only be called when point is at t Line 3644  Should only be called when point is at t
3644                (end-region (if (eq kind 1) (point) (point-max))))                (end-region (if (eq kind 1) (point) (point-max))))
3645             (delete-region start-region end-region)             (delete-region start-region end-region)
3646             (term-unwrap-line)             (term-unwrap-line)
3647             (if (eq kind 1)             (when (eq kind 1)
3648                 (term-insert-char ?\n row))               (term-insert-char ?\n row))
3649             (setq term-current-column nil)             (setq term-current-column nil)
3650             (setq term-current-row nil)             (setq term-current-row nil)
3651             (term-goto row col)))))             (term-goto row col)))))
# Line 3624  Should only be called when point is at t Line 3706  Should only be called when point is at t
3706      (term-insert-char ?\n lines)      (term-insert-char ?\n lines)
3707      (goto-char start)))      (goto-char start)))
3708    
3709  (defun term-set-output-log (name)  (defun term-start-output-log (name)
3710    "Record raw inferior process output in a buffer."    "Record raw inferior process output in a buffer."
3711    (interactive (list (if term-log-buffer    (interactive (list (if term-log-buffer
3712                           nil                           nil
# Line 3646  Should only be called when point is at t Line 3728  Should only be called when point is at t
3728      (message "Recording terminal emulator output into buffer \"%s\""      (message "Recording terminal emulator output into buffer \"%s\""
3729               (buffer-name term-log-buffer))))               (buffer-name term-log-buffer))))
3730    
3731  (defun term-stop-photo ()  (defun term-stop-output-log ()
3732    "Discontinue raw inferior process logging."    "Discontinue raw inferior process logging."
3733    (interactive)    (interactive)
3734    (term-set-output-log nil))    (term-start-output-log nil))
3735    
3736  (defun term-show-maximum-output ()  (defun term-show-maximum-output ()
3737    "Put the end of the buffer at the bottom of the window."    "Put the end of the buffer at the bottom of the window."

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

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