emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/term.el


From: Dan Nicolaescu
Subject: [Emacs-diffs] Changes to emacs/lisp/term.el
Date: Sun, 26 Sep 2004 14:59:47 -0400

Index: emacs/lisp/term.el
diff -c emacs/lisp/term.el:1.58 emacs/lisp/term.el:1.59
*** emacs/lisp/term.el:1.58     Mon Sep 20 15:59:31 2004
--- emacs/lisp/term.el  Sun Sep 26 18:39:10 2004
***************
*** 1,6 ****
  ;;; term.el --- general command interpreter in a window stuff
  
! ;;; Copyright (C) 1988, 1990, 1992, 1994, 1995 Free Software Foundation, Inc.
  
  ;; Author: Per Bothner <address@hidden>
  ;; Based on comint mode written by: Olin Shivers <address@hidden>
--- 1,6 ----
  ;;; term.el --- general command interpreter in a window stuff
  
! ;;; Copyright (C) 1988, 1990, 1992, 1994, 1995, 2004 Free Software 
Foundation, Inc.
  
  ;; Author: Per Bothner <address@hidden>
  ;; Based on comint mode written by: Olin Shivers <address@hidden>
***************
*** 676,682 ****
  (defvar term-terminal-menu)
  
  ;;; Let's silence the byte-compiler -mm
- (defvar term-ansi-at-eval-string nil)
  (defvar term-ansi-at-host nil)
  (defvar term-ansi-at-dir nil)
  (defvar term-ansi-at-user nil)
--- 676,681 ----
***************
*** 692,700 ****
  (defvar term-ansi-current-highlight 0)
  (defvar term-ansi-current-reverse 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)
  
  ;;; Four should be enough, if you want more, just add. -mm
  (defvar term-terminal-more-parameters 0)
--- 691,696 ----
***************
*** 917,922 ****
--- 913,921 ----
      (define-key term-raw-map [backspace] 'term-send-backspace)
      (define-key term-raw-map [home] 'term-send-home)
      (define-key term-raw-map [end] 'term-send-end)
+     (define-key term-raw-map [S-prior] 'scroll-down)
+     (define-key term-raw-map [S-next] 'scroll-up)
+     (define-key term-raw-map [S-insert] 'term-paste)
      (define-key term-raw-map [prior] 'term-send-prior)
      (define-key term-raw-map [next] 'term-send-next)))
  
***************
*** 932,937 ****
--- 931,957 ----
  
  (put 'term-mode 'mode-class 'special)
  
+ 
+ ;;; Use this variable as a display table for `term-mode'.
+ (defvar term-display-table
+   (let ((dt (or (copy-sequence standard-display-table)
+               (make-display-table)))
+         i)
+     ;; avoid changing the display table for ^J
+     (setq i 0) 
+     (while (< i 10)
+       (aset dt i (vector i))
+       (setq i (1+ i)))
+     (setq i 11) 
+     (while (< i 32)
+       (aset dt i (vector i))
+       (setq i (1+ i)))
+     (setq i 128)
+     (while (< i 256)
+       (aset dt i (vector i))
+       (setq i (1+ i)))
+     dt))
+ 
  (defun term-mode ()
    "Major mode for interacting with an inferior interpreter.
  The interpreter name is same as buffer name, sans the asterisks.
***************
*** 981,986 ****
--- 1001,1009 ----
    (setq major-mode 'term-mode)
    (setq mode-name "Term")
    (use-local-map term-mode-map)
+   ;; we do not want indent to sneak in any tabs
+   (setq indent-tabs-mode nil)
+   (setq buffer-display-table term-display-table)
    (make-local-variable 'term-home-marker)
    (setq term-home-marker (copy-marker 0))
    (make-local-variable 'term-saved-home-marker)
***************
*** 1184,1189 ****
--- 1207,1217 ----
                                        ((eq arg '-) -1)
                                        (t (1- arg)))))))
  
+ (defun term-paste ()
+   "Insert the last stretch of killed text at point."
+   (interactive)
+    (term-send-raw-string (current-kill 0)))
+ 
  ;; Which would be better:  "\e[A" or "\eOA"? readline accepts either.
  ;; For my configuration it's definitely better \eOA but YMMV. -mm
  ;; For example: vi works with \eOA while elm wants \e[A ...
***************
*** 1195,1202 ****
  (defun term-send-end   () (interactive) (term-send-raw-string "\e[4~"))
  (defun term-send-prior () (interactive) (term-send-raw-string "\e[5~"))
  (defun term-send-next  () (interactive) (term-send-raw-string "\e[6~"))
! (defun term-send-del   () (interactive) (term-send-raw-string "\C-?"))
! (defun term-send-backspace  () (interactive) (term-send-raw-string "\C-H"))
  
  (defun term-char-mode ()
    "Switch to char (\"raw\") sub-mode of term mode.
--- 1223,1230 ----
  (defun term-send-end   () (interactive) (term-send-raw-string "\e[4~"))
  (defun term-send-prior () (interactive) (term-send-raw-string "\e[5~"))
  (defun term-send-next  () (interactive) (term-send-raw-string "\e[6~"))
! (defun term-send-del   () (interactive) (term-send-raw-string "\e[3~"))
! (defun term-send-backspace  () (interactive) (term-send-raw-string "\C-?"))
  
  (defun term-char-mode ()
    "Switch to char (\"raw\") sub-mode of term mode.
***************
*** 1366,1379 ****
    "%s%s:li#%d:co#%d:cl=\\E[H\\E[J:cd=\\E[J:bs:am:xn:cm=\\E[%%i%%d;%%dH\
  :nd=\\E[C:up=\\E[A:ce=\\E[K:ho=\\E[H:pt\
  :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\
  :dc=\\E[P:DC=\\E[%%dP:IC=\\E[%%d@:im=\\E[4h:ei=\\E[4l:mi:\
  :so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\E[m\
  :UP=\\E[%%dA:DO=\\E[%%dB:LE=\\E[%%dD:RI=\\E[%%dC\
  :kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E[5~:@7=\\E[4~:kh=\\E[1~\
  :mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#8:pa#64:AB=\\E[4%%dm:AF=\\E[3%%dm:cr=^M\
! :bl=^G:do=^J:le=^H:ta=^I:se=\E[27m:ue=\E24m:"
  ;;; : -undefine ic
    "termcap capabilities supported")
  
  ;;; This auxiliary function cranks up the process for term-exec in
--- 1394,1408 ----
    "%s%s:li#%d:co#%d:cl=\\E[H\\E[J:cd=\\E[J:bs:am:xn:cm=\\E[%%i%%d;%%dH\
  :nd=\\E[C:up=\\E[A:ce=\\E[K:ho=\\E[H:pt\
  :al=\\E[L:dl=\\E[M:DL=\\E[%%dM:AL=\\E[%%dL:cs=\\E[%%i%%d;%%dr:sf=^J\
  :dc=\\E[P:DC=\\E[%%dP:IC=\\E[%%d@:im=\\E[4h:ei=\\E[4l:mi:\
  :so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:md=\\E[1m:mr=\\E[7m:me=\\E[m\
  :UP=\\E[%%dA:DO=\\E[%%dB:LE=\\E[%%dD:RI=\\E[%%dC\
  :kl=\\EOD:kd=\\EOB:kr=\\EOC:ku=\\EOA:kN=\\E[6~:kP=\\E[5~:@7=\\E[4~:kh=\\E[1~\
  :mk=\\E[8m:cb=\\E[1K:op=\\E[39;49m:Co#8:pa#64:AB=\\E[4%%dm:AF=\\E[3%%dm:cr=^M\
! :bl=^G:do=^J:le=^H:ta=^I:se=\E[27m:ue=\E24m\
! :kb=^?:kD=^[[3~:sc=\E7:rc=\E8:"
  ;;; : -undefine ic
+ ;;; don't define :te=\\E[2J\\E[?47l\\E8:ti=\\E7\\E[?47h\
    "termcap capabilities supported")
  
  ;;; This auxiliary function cranks up the process for term-exec in
***************
*** 1400,1408 ****
        (process-connection-type t)
        ;; We should suppress conversion of end-of-line format.
        (inhibit-eol-conversion t)
!       ;; inhibit-eol-conversion doesn't seem to do the job, but this does.
!       (coding-system-for-read 'unknown-unix)
!       )
      (apply 'start-process name buffer
           "/bin/sh" "-c"
           (format "stty -nl echo rows %d columns %d sane 2>/dev/null;\
--- 1429,1438 ----
        (process-connection-type t)
        ;; We should suppress conversion of end-of-line format.
        (inhibit-eol-conversion t)
!       ;; The process's output contains not just chars but also binary
!       ;; escape codes, so we need to see the raw output.  We will have to
!       ;; do the decoding by hand on the parts that are made of chars.
!       (coding-system-for-read 'binary))
      (apply 'start-process name buffer
           "/bin/sh" "-c"
           (format "stty -nl echo rows %d columns %d sane 2>/dev/null;\
***************
*** 2693,2699 ****
                   (if (not funny) (setq funny str-length))
                   (cond ((> funny i)
                          (cond ((eq term-terminal-state 1)
!                                (term-move-columns 1)
                                 (setq term-terminal-state 0)))
                          (setq count (- funny i))
                          (setq temp (- (+ (term-horizontal-column) count)
--- 2723,2734 ----
                   (if (not funny) (setq funny str-length))
                   (cond ((> funny i)
                          (cond ((eq term-terminal-state 1)
!                                ;; We are in state 1, we need to wrap
!                                ;; around.  Go to the beginning of
!                                ;; the next line and switch to state
!                                ;; 0.
!                                (term-down 1)
!                                (term-move-columns (- (term-current-column)))
                                 (setq term-terminal-state 0)))
                          (setq count (- funny i))
                          (setq temp (- (+ (term-horizontal-column) count)
***************
*** 2702,2707 ****
--- 2737,2743 ----
                                ((> count temp) ;; Some chars fit.
                                 ;; This iteration, handle only what fits.
                                 (setq count (- count temp))
+                                (setq temp 0)
                                 (setq funny (+ count i)))
                                ((or (not (or term-pager-count
                                              term-scroll-with-delete))
***************
*** 2722,2728 ****
                          ;; following point if not eob nor insert-mode.
                          (let ((old-column (current-column))
                                columns pos)
!                           (insert (substring str i funny))
                            (setq term-current-column (current-column)
                                  columns (- term-current-column old-column))
                            (when (not (or (eobp) term-insert-mode))
--- 2758,2764 ----
                          ;; following point if not eob nor insert-mode.
                          (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))
                            (when (not (or (eobp) term-insert-mode))
***************
*** 2741,2747 ****
                                 (setq term-terminal-state 1)))
                          (setq i (1- funny)))
                         ((and (setq term-terminal-state 0)
!                              (eq char ?\^I)) ; TAB
                          ;; FIXME:  Does not handle line wrap!
                          (setq count (term-current-column))
                          (setq count (+ count 8 (- (mod count 8))))
--- 2777,2783 ----
                                 (setq term-terminal-state 1)))
                          (setq i (1- funny)))
                         ((and (setq term-terminal-state 0)
!                              (eq char ?\^I)) ; TAB (terminfo: ht)
                          ;; FIXME:  Does not handle line wrap!
                          (setq count (term-current-column))
                          (setq count (+ count 8 (- (mod count 8))))
***************
*** 2768,2774 ****
                          (if (not (and term-kill-echo-list
                                        (term-check-kill-echo-list)))
                              (term-down 1 t)))
!                        ((eq char ?\b)
                          (term-move-columns -1))
                         ((eq char ?\033) ; Escape
                          (setq term-terminal-state 2))
--- 2804,2810 ----
                          (if (not (and term-kill-echo-list
                                        (term-check-kill-echo-list)))
                              (term-down 1 t)))
!                        ((eq char ?\b)  ;; (terminfo: cub1)
                          (term-move-columns -1))
                         ((eq char ?\033) ; Escape
                          (setq term-terminal-state 2))
***************
*** 2818,2830 ****
                         ((eq char ?M) ;; scroll reversed
                          (term-insert-lines 1)
                          (setq term-terminal-state 0))
!                        ((eq char ?7) ;; Save cursor
                          (term-handle-deferred-scroll)
                          (setq term-saved-cursor
                                (cons (term-current-row)
                                      (term-horizontal-column)))
                          (setq term-terminal-state 0))
!                        ((eq char ?8) ;; Restore cursor
                          (if term-saved-cursor
                              (term-goto (car term-saved-cursor)
                                         (cdr term-saved-cursor)))
--- 2854,2866 ----
                         ((eq char ?M) ;; scroll reversed
                          (term-insert-lines 1)
                          (setq term-terminal-state 0))
!                        ((eq char ?7) ;; Save cursor (terminfo: sc)
                          (term-handle-deferred-scroll)
                          (setq term-saved-cursor
                                (cons (term-current-row)
                                      (term-horizontal-column)))
                          (setq term-terminal-state 0))
!                        ((eq char ?8) ;; Restore cursor (terminfo: rc)
                          (if term-saved-cursor
                              (term-goto (car term-saved-cursor)
                                         (cdr term-saved-cursor)))
***************
*** 2976,2988 ****
     ((eq parameter 8)
      (setq term-ansi-current-invisible 1))
  
! ;;; Reset reverse (i.e. terminfo rmso)
     ((eq parameter 24)
!     (setq term-ansi-current-reverse 0))
  
! ;;; Reset underline (i.e. terminfo rmul)
     ((eq parameter 27)
!     (setq term-ansi-current-underline 0))
  
  ;;; Foreground
     ((and (>= parameter 30) (<= parameter 37))
--- 3012,3024 ----
     ((eq parameter 8)
      (setq term-ansi-current-invisible 1))
  
! ;;; Reset underline (i.e. terminfo rmul)
     ((eq parameter 24)
!     (setq term-ansi-current-underline 0))
  
! ;;; Reset reverse (i.e. terminfo rmso)
     ((eq parameter 27)
!     (setq term-ansi-current-reverse 0))
  
  ;;; Foreground
     ((and (>= parameter 30) (<= parameter 37))
***************
*** 3097,3103 ****
      (term-goto
       (1- term-terminal-previous-parameter)
       (1- term-terminal-parameter)))
!    ;; \E[A - cursor up
     ((eq char ?A)
      (term-handle-deferred-scroll)
      (term-down (- (max 1 term-terminal-parameter)) t))
--- 3133,3139 ----
      (term-goto
       (1- term-terminal-previous-parameter)
       (1- term-terminal-parameter)))
!    ;; \E[A - cursor up (terminfo: cuu1)
     ((eq char ?A)
      (term-handle-deferred-scroll)
      (term-down (- (max 1 term-terminal-parameter)) t))
***************
*** 3110,3122 ****
     ;; \E[D - cursor left
     ((eq char ?D)
      (term-move-columns (- (max 1 term-terminal-parameter))))
!    ;; \E[J - clear to end of screen
     ((eq char ?J)
      (term-erase-in-display term-terminal-parameter))
!    ;; \E[K - clear to end of line
     ((eq char ?K)
      (term-erase-in-line term-terminal-parameter))
!    ;; \E[L - insert lines
     ((eq char ?L)
      (term-insert-lines (max 1 term-terminal-parameter)))
     ;; \E[M - delete lines
--- 3146,3158 ----
     ;; \E[D - cursor left
     ((eq char ?D)
      (term-move-columns (- (max 1 term-terminal-parameter))))
!    ;; \E[J - clear to end of screen (terminfo: ed, clear)
     ((eq char ?J)
      (term-erase-in-display term-terminal-parameter))
!    ;; \E[K - clear to end of line (terminfo: el, el1)
     ((eq char ?K)
      (term-erase-in-line term-terminal-parameter))
!    ;; \E[L - insert lines (terminfo: il, il1)
     ((eq char ?L)
      (term-insert-lines (max 1 term-terminal-parameter)))
     ;; \E[M - delete lines
***************
*** 3130,3148 ****
      (term-insert-spaces (max 1 term-terminal-parameter)))
     ;; \E[?h - DEC Private Mode Set
     ((eq char ?h)
!     (cond ((eq term-terminal-parameter 4)
           (setq term-insert-mode t))
!         ((eq term-terminal-parameter 47)
!          (term-switch-to-alternate-sub-buffer t))))
     ;; \E[?l - DEC Private Mode Reset
     ((eq char ?l)
!     (cond ((eq term-terminal-parameter 4)
           (setq term-insert-mode nil))
!         ((eq term-terminal-parameter 47)
!          (term-switch-to-alternate-sub-buffer nil))))
  
  ;;; Modified to allow ansi coloring -mm
!    ;; \E[m - Set/reset standard mode
     ((eq char ?m)
      (when (= term-terminal-more-parameters 1)
        (if (>= term-terminal-previous-parameter-4 0)
--- 3166,3187 ----
      (term-insert-spaces (max 1 term-terminal-parameter)))
     ;; \E[?h - DEC Private Mode Set
     ((eq char ?h)
!     (cond ((eq term-terminal-parameter 4)  ;; (terminfo: smir)
           (setq term-insert-mode t))
!         ;; ((eq term-terminal-parameter 47) ;; (terminfo: smcup)
!         ;; (term-switch-to-alternate-sub-buffer t))
!         ))
     ;; \E[?l - DEC Private Mode Reset
     ((eq char ?l)
!     (cond ((eq term-terminal-parameter 4)  ;; (terminfo: rmir)
           (setq term-insert-mode nil))
!         ;; ((eq term-terminal-parameter 47) ;; (terminfo: rmcup)
!         ;; (term-switch-to-alternate-sub-buffer nil))
!         ))
  
  ;;; Modified to allow ansi coloring -mm
!    ;; \E[m - Set/reset modes, set bg/fg 
!    ;;(terminfo: smso,rmso,smul,rmul,rev,bold,sgr0,invis,op,setab,setaf)
     ((eq char ?m)
      (when (= term-terminal-more-parameters 1)
        (if (>= term-terminal-previous-parameter-4 0)
***************
*** 3186,3217 ****
            (not (and (= term-scroll-start 0)
                      (= term-scroll-end term-height))))))
  
! (defun term-switch-to-alternate-sub-buffer (set)
!   ;; If asked to switch to (from) the alternate sub-buffer, and already (not)
!   ;; using it, do nothing.  This test is needed for some programs (including
!   ;; Emacs) that emit the ti termcap string twice, for unknown reason.
!   (term-handle-deferred-scroll)
!   (if (eq set (not (term-using-alternate-sub-buffer)))
!       (let ((row (term-current-row))
!           (col (term-horizontal-column)))
!       (cond (set
!              (goto-char (point-max))
!              (if (not (eq (preceding-char) ?\n))
!                  (term-insert-char ?\n 1))
!              (setq term-scroll-with-delete t)
!              (setq term-saved-home-marker (copy-marker term-home-marker))
!              (set-marker term-home-marker (point)))
!             (t
!              (setq term-scroll-with-delete
!                    (not (and (= term-scroll-start 0)
!                              (= term-scroll-end term-height))))
!              (set-marker term-home-marker term-saved-home-marker)
!              (set-marker term-saved-home-marker nil)
!              (setq term-saved-home-marker nil)
!              (goto-char term-home-marker)))
!       (setq term-current-column nil)
!       (setq term-current-row 0)
!       (term-goto row col))))
  
  ;; Default value for the symbol term-command-hook.
  
--- 3225,3256 ----
            (not (and (= term-scroll-start 0)
                      (= term-scroll-end term-height))))))
  
! ;; (defun term-switch-to-alternate-sub-buffer (set)
! ;;   ;; If asked to switch to (from) the alternate sub-buffer, and already 
(not)
! ;;   ;; using it, do nothing.  This test is needed for some programs 
(including
! ;;   ;; Emacs) that emit the ti termcap string twice, for unknown reason.
! ;;   (term-handle-deferred-scroll)
! ;;   (if (eq set (not (term-using-alternate-sub-buffer)))
! ;;       (let ((row (term-current-row))
! ;;        (col (term-horizontal-column)))
! ;;    (cond (set
! ;;           (goto-char (point-max))
! ;;           (if (not (eq (preceding-char) ?\n))
! ;;               (term-insert-char ?\n 1))
! ;;           (setq term-scroll-with-delete t)
! ;;           (setq term-saved-home-marker (copy-marker term-home-marker))
! ;;           (set-marker term-home-marker (point)))
! ;;          (t
! ;;           (setq term-scroll-with-delete
! ;;                 (not (and (= term-scroll-start 0)
! ;;                           (= term-scroll-end term-height))))
! ;;           (set-marker term-home-marker term-saved-home-marker)
! ;;           (set-marker term-saved-home-marker nil)
! ;;           (setq term-saved-home-marker nil)
! ;;           (goto-char term-home-marker)))
! ;;    (setq term-current-column nil)
! ;;    (setq term-current-row 0)
! ;;    (term-goto row col))))
  
  ;; Default value for the symbol term-command-hook.
  
***************
*** 3521,3531 ****
    (if (not (bolp)) (insert-before-markers ?\n)))
  
  (defun term-erase-in-line (kind)
!   (if (> kind 1) ;; erase left of point
        (let ((cols (term-horizontal-column)) (saved-point (point)))
        (term-vertical-motion 0)
        (delete-region (point) saved-point)
!       (term-insert-char ?\n cols)))
    (if (not (eq kind 1)) ;; erase right of point
        (let ((saved-point (point))
            (wrapped (and (zerop (term-horizontal-column))
--- 3560,3570 ----
    (if (not (bolp)) (insert-before-markers ?\n)))
  
  (defun term-erase-in-line (kind)
!   (if (= kind 1) ;; erase left of point
        (let ((cols (term-horizontal-column)) (saved-point (point)))
        (term-vertical-motion 0)
        (delete-region (point) saved-point)
!       (term-insert-char ?  cols)))
    (if (not (eq kind 1)) ;; erase right of point
        (let ((saved-point (point))
            (wrapped (and (zerop (term-horizontal-column))
***************
*** 3624,3630 ****
      (term-insert-char ?\n lines)
      (goto-char start)))
  
! (defun term-set-output-log (name)
    "Record raw inferior process output in a buffer."
    (interactive (list (if term-log-buffer
                         nil
--- 3663,3669 ----
      (term-insert-char ?\n lines)
      (goto-char start)))
  
! (defun term-start-output-log (name)
    "Record raw inferior process output in a buffer."
    (interactive (list (if term-log-buffer
                         nil
***************
*** 3646,3655 ****
      (message "Recording terminal emulator output into buffer \"%s\""
             (buffer-name term-log-buffer))))
  
! (defun term-stop-photo ()
    "Discontinue raw inferior process logging."
    (interactive)
!   (term-set-output-log nil))
  
  (defun term-show-maximum-output ()
    "Put the end of the buffer at the bottom of the window."
--- 3685,3694 ----
      (message "Recording terminal emulator output into buffer \"%s\""
             (buffer-name term-log-buffer))))
  
! (defun term-stop-output-log ()
    "Discontinue raw inferior process logging."
    (interactive)
!   (term-start-output-log nil))
  
  (defun term-show-maximum-output ()
    "Put the end of the buffer at the bottom of the window."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]