diff options
| author | Dan Nicolaescu | 2006-01-15 19:36:10 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2006-01-15 19:36:10 +0000 |
| commit | 14397ea7567ea807cab19d1248244f6eb383d78e (patch) | |
| tree | 4703ee5d1c9af24152c40638f697fecaa59fb7b0 | |
| parent | 98eab4e47742190fb317bc398dde0ed126241ab5 (diff) | |
| download | emacs-14397ea7567ea807cab19d1248244f6eb383d78e.tar.gz emacs-14397ea7567ea807cab19d1248244f6eb383d78e.zip | |
* e/eterm-color.ti: Re-enable the ri entry. Add kich1.
* term.el (term-raw-map): Add mapping for insert.
(term-send-insert): New.
(term-mode): Make variables local here instead of doing it in
`term-emulate-terminal'.
(term-emulate-terminal): Delete incorrect optimization for cr+lf.
Scroll reverse needs to take into account the scroll
region. Saving and restoring the cursor should save the color
attributes too.
(term-reset-terminal): Reset the scroll region.
(term-handle-ansi-escape): Cursor up and down should take into
account the scroll region.
(term-set-scroll-region): Renamed from `term-scroll-region'. Move
to 0,0 after setting the region.
(term-handle-scroll): Handle scroll up.
(term-down): Fix off by one error.
(term-delete-lines): Do not delete outside the scroll region.
(term-insert-lines): Take into account the scroll region.
| -rw-r--r-- | etc/ChangeLog | 4 | ||||
| -rw-r--r-- | etc/e/eterm-color | bin | 1155 -> 1163 bytes | |||
| -rw-r--r-- | etc/e/eterm-color.ti | 3 | ||||
| -rw-r--r-- | lisp/ChangeLog | 20 | ||||
| -rw-r--r-- | lisp/term.el | 204 |
5 files changed, 159 insertions, 72 deletions
diff --git a/etc/ChangeLog b/etc/ChangeLog index e15f24f8537..847907bbe73 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2006-01-15 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * e/eterm-color.ti: Re-enable the ri entry. Add kich1. | ||
| 4 | |||
| 1 | 2006-01-13 Richard M. Stallman <rms@gnu.org> | 5 | 2006-01-13 Richard M. Stallman <rms@gnu.org> |
| 2 | 6 | ||
| 3 | * emacs.1: +N applies only to next file. | 7 | * emacs.1: +N applies only to next file. |
diff --git a/etc/e/eterm-color b/etc/e/eterm-color index de84f4c909c..5a208473e3e 100644 --- a/etc/e/eterm-color +++ b/etc/e/eterm-color | |||
| Binary files differ | |||
diff --git a/etc/e/eterm-color.ti b/etc/e/eterm-color.ti index bb066ca9bd5..32e6aa80736 100644 --- a/etc/e/eterm-color.ti +++ b/etc/e/eterm-color.ti | |||
| @@ -47,12 +47,13 @@ eterm-color|Emacs term.el terminal emulator term-protocol-version 0.96, | |||
| 47 | kdch1=\E[3~, | 47 | kdch1=\E[3~, |
| 48 | kend=\E[4~, | 48 | kend=\E[4~, |
| 49 | khome=\E[1~, | 49 | khome=\E[1~, |
| 50 | kich1=\E[2~, | ||
| 50 | knp=\E[6~, | 51 | knp=\E[6~, |
| 51 | kpp=\E[5~, | 52 | kpp=\E[5~, |
| 52 | op=\E[39;49m, | 53 | op=\E[39;49m, |
| 53 | rc=\E8, | 54 | rc=\E8, |
| 54 | rev=\E[7m, | 55 | rev=\E[7m, |
| 55 | # ri=\EM, #temporarily disable, it causes problems for mutt | 56 | ri=\EM, |
| 56 | rmir=\E[4l, | 57 | rmir=\E[4l, |
| 57 | rmso=\E[27m, | 58 | rmso=\E[27m, |
| 58 | rmul=\E[24m, | 59 | rmul=\E[24m, |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 84fbb0126d4..87a8c40d176 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,23 @@ | |||
| 1 | 2006-01-15 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * term.el (term-raw-map): Add mapping for insert. | ||
| 4 | (term-send-insert): New. | ||
| 5 | (term-mode): Make variables local here instead of doing it in | ||
| 6 | `term-emulate-terminal'. | ||
| 7 | (term-emulate-terminal): Delete incorrect optimization for cr+lf. | ||
| 8 | Scroll reverse needs to take into account the scroll | ||
| 9 | region. Saving and restoring the cursor should save the color | ||
| 10 | attributes too. | ||
| 11 | (term-reset-terminal): Reset the scroll region. | ||
| 12 | (term-handle-ansi-escape): Cursor up and down should take into | ||
| 13 | account the scroll region. | ||
| 14 | (term-set-scroll-region): Renamed from `term-scroll-region'. Move | ||
| 15 | to 0,0 after setting the region. | ||
| 16 | (term-handle-scroll): Handle scroll up. | ||
| 17 | (term-down): Fix off by one error. | ||
| 18 | (term-delete-lines): Do not delete outside the scroll region. | ||
| 19 | (term-insert-lines): Take into account the scroll region. | ||
| 20 | |||
| 1 | 2006-01-15 Stefan Monnier <monnier@iro.umontreal.ca> | 21 | 2006-01-15 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 22 | ||
| 3 | * textmodes/ispell.el (ispell-internal-change-dictionary) | 23 | * textmodes/ispell.el (ispell-internal-change-dictionary) |
diff --git a/lisp/term.el b/lisp/term.el index 62728f45a08..be4aefaba72 100644 --- a/lisp/term.el +++ b/lisp/term.el | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | ;;; term.el --- general command interpreter in a window stuff | 1 | ;;; term.el --- general command interpreter in a window stuff |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1988, 1990, 1992, 1994, 1995, 2002, 2003, | 3 | ;; Copyright (C) 1988, 1990, 1992, 1994, 1995, 2002, 2003, |
| 4 | ;; 2004, 2005 Free Software Foundation, Inc. | 4 | ;; 2004, 2005, 2006 Free Software Foundation, Inc. |
| 5 | 5 | ||
| 6 | ;; Author: Per Bothner <per@bothner.com> | 6 | ;; Author: Per Bothner <per@bothner.com> |
| 7 | ;; Maintainer: Dan Nicolaescu <dann@ics.uci.edu>, Per Bothner <per@bothner.com> | 7 | ;; Maintainer: Dan Nicolaescu <dann@ics.uci.edu>, Per Bothner <per@bothner.com> |
| @@ -917,6 +917,7 @@ is buffer-local.") | |||
| 917 | (define-key term-raw-map [backspace] 'term-send-backspace) | 917 | (define-key term-raw-map [backspace] 'term-send-backspace) |
| 918 | (define-key term-raw-map [home] 'term-send-home) | 918 | (define-key term-raw-map [home] 'term-send-home) |
| 919 | (define-key term-raw-map [end] 'term-send-end) | 919 | (define-key term-raw-map [end] 'term-send-end) |
| 920 | (define-key term-raw-map [insert] 'term-send-insert) | ||
| 920 | (define-key term-raw-map [S-prior] 'scroll-down) | 921 | (define-key term-raw-map [S-prior] 'scroll-down) |
| 921 | (define-key term-raw-map [S-next] 'scroll-up) | 922 | (define-key term-raw-map [S-next] 'scroll-up) |
| 922 | (define-key term-raw-map [S-insert] 'term-paste) | 923 | (define-key term-raw-map [S-insert] 'term-paste) |
| @@ -1068,6 +1069,13 @@ Entry to this mode runs the hooks on `term-mode-hook'." | |||
| 1068 | (make-local-variable 'term-ansi-current-reverse) | 1069 | (make-local-variable 'term-ansi-current-reverse) |
| 1069 | (make-local-variable 'term-ansi-current-invisible) | 1070 | (make-local-variable 'term-ansi-current-invisible) |
| 1070 | 1071 | ||
| 1072 | (make-local-variable 'term-terminal-parameter) | ||
| 1073 | (make-local-variable 'term-terminal-previous-parameter) | ||
| 1074 | (make-local-variable 'term-terminal-previous-parameter-2) | ||
| 1075 | (make-local-variable 'term-terminal-previous-parameter-3) | ||
| 1076 | (make-local-variable 'term-terminal-previous-parameter-4) | ||
| 1077 | (make-local-variable 'term-terminal-more-parameters) | ||
| 1078 | |||
| 1071 | (make-local-variable 'term-terminal-state) | 1079 | (make-local-variable 'term-terminal-state) |
| 1072 | (make-local-variable 'term-kill-echo-list) | 1080 | (make-local-variable 'term-kill-echo-list) |
| 1073 | (make-local-variable 'term-start-line-column) | 1081 | (make-local-variable 'term-start-line-column) |
| @@ -1119,7 +1127,7 @@ Entry to this mode runs the hooks on `term-mode-hook'." | |||
| 1119 | (setq term-start-line-column nil) | 1127 | (setq term-start-line-column nil) |
| 1120 | (setq term-current-row nil) | 1128 | (setq term-current-row nil) |
| 1121 | (setq term-current-column nil) | 1129 | (setq term-current-column nil) |
| 1122 | (term-scroll-region 0 height)) | 1130 | (term-set-scroll-region 0 height)) |
| 1123 | 1131 | ||
| 1124 | ;; Recursive routine used to check if any string in term-kill-echo-list | 1132 | ;; Recursive routine used to check if any string in term-kill-echo-list |
| 1125 | ;; matches part of the buffer before point. | 1133 | ;; matches part of the buffer before point. |
| @@ -1227,6 +1235,7 @@ without any interpretation." | |||
| 1227 | (defun term-send-right () (interactive) (term-send-raw-string "\eOC")) | 1235 | (defun term-send-right () (interactive) (term-send-raw-string "\eOC")) |
| 1228 | (defun term-send-left () (interactive) (term-send-raw-string "\eOD")) | 1236 | (defun term-send-left () (interactive) (term-send-raw-string "\eOD")) |
| 1229 | (defun term-send-home () (interactive) (term-send-raw-string "\e[1~")) | 1237 | (defun term-send-home () (interactive) (term-send-raw-string "\e[1~")) |
| 1238 | (defun term-send-insert() (interactive) (term-send-raw-string "\e[2~")) | ||
| 1230 | (defun term-send-end () (interactive) (term-send-raw-string "\e[4~")) | 1239 | (defun term-send-end () (interactive) (term-send-raw-string "\e[4~")) |
| 1231 | (defun term-send-prior () (interactive) (term-send-raw-string "\e[5~")) | 1240 | (defun term-send-prior () (interactive) (term-send-raw-string "\e[5~")) |
| 1232 | (defun term-send-next () (interactive) (term-send-raw-string "\e[6~")) | 1241 | (defun term-send-next () (interactive) (term-send-raw-string "\e[6~")) |
| @@ -2748,7 +2757,7 @@ See `term-prompt-regexp'." | |||
| 2748 | ;; around. Go to the beginning of | 2757 | ;; around. Go to the beginning of |
| 2749 | ;; the next line and switch to state | 2758 | ;; the next line and switch to state |
| 2750 | ;; 0. | 2759 | ;; 0. |
| 2751 | (term-down 1) | 2760 | (term-down 1 t) |
| 2752 | (term-move-columns (- (term-current-column))) | 2761 | (term-move-columns (- (term-current-column))) |
| 2753 | (setq term-terminal-state 0))) | 2762 | (setq term-terminal-state 0))) |
| 2754 | (setq count (- funny i)) | 2763 | (setq count (- funny i)) |
| @@ -2786,7 +2795,7 @@ See `term-prompt-regexp'." | |||
| 2786 | (setq pos (point)) | 2795 | (setq pos (point)) |
| 2787 | (term-move-columns columns) | 2796 | (term-move-columns columns) |
| 2788 | (delete-region pos (point))) | 2797 | (delete-region pos (point))) |
| 2789 | ;; In insert if the if the current line | 2798 | ;; In insert mode if the current line |
| 2790 | ;; has become too long it needs to be | 2799 | ;; has become too long it needs to be |
| 2791 | ;; chopped off. | 2800 | ;; chopped off. |
| 2792 | (when term-insert-mode | 2801 | (when term-insert-mode |
| @@ -2825,25 +2834,12 @@ See `term-prompt-regexp'." | |||
| 2825 | (when (= term-width (term-current-column)) | 2834 | (when (= term-width (term-current-column)) |
| 2826 | (term-move-columns -1)))) | 2835 | (term-move-columns -1)))) |
| 2827 | ((eq char ?\r) ;; (terminfo: cr) | 2836 | ((eq char ?\r) ;; (terminfo: cr) |
| 2828 | ;; Optimize CRLF at end of buffer: | 2837 | (term-vertical-motion 0) |
| 2829 | (cond ((and (< (setq temp (1+ i)) str-length) | 2838 | (setq term-current-column term-start-line-column)) |
| 2830 | (eq (aref str temp) ?\n) | ||
| 2831 | (= (point) (point-max)) | ||
| 2832 | (not (or term-pager-count | ||
| 2833 | term-kill-echo-list | ||
| 2834 | term-scroll-with-delete))) | ||
| 2835 | (insert ?\n) | ||
| 2836 | (term-adjust-current-row-cache 1) | ||
| 2837 | (setq term-start-line-column 0) | ||
| 2838 | (setq term-current-column 0) | ||
| 2839 | (setq i temp)) | ||
| 2840 | (t ;; Not followed by LF or can't optimize: | ||
| 2841 | (term-vertical-motion 0) | ||
| 2842 | (setq term-current-column term-start-line-column)))) | ||
| 2843 | ((eq char ?\n) ;; (terminfo: cud1, ind) | 2839 | ((eq char ?\n) ;; (terminfo: cud1, ind) |
| 2844 | (if (not (and term-kill-echo-list | 2840 | (unless (and term-kill-echo-list |
| 2845 | (term-check-kill-echo-list))) | 2841 | (term-check-kill-echo-list)) |
| 2846 | (term-down 1 t))) | 2842 | (term-down 1 t))) |
| 2847 | ((eq char ?\b) ;; (terminfo: cub1) | 2843 | ((eq char ?\b) ;; (terminfo: cub1) |
| 2848 | (term-move-columns -1)) | 2844 | (term-move-columns -1)) |
| 2849 | ((eq char ?\033) ; Escape | 2845 | ((eq char ?\033) ; Escape |
| @@ -2874,12 +2870,6 @@ See `term-prompt-regexp'." | |||
| 2874 | ;;; Note that now the init value of term-terminal-previous-parameter has | 2870 | ;;; Note that now the init value of term-terminal-previous-parameter has |
| 2875 | ;;; been changed to -1 | 2871 | ;;; been changed to -1 |
| 2876 | 2872 | ||
| 2877 | (make-local-variable 'term-terminal-parameter) | ||
| 2878 | (make-local-variable 'term-terminal-previous-parameter) | ||
| 2879 | (make-local-variable 'term-terminal-previous-parameter-2) | ||
| 2880 | (make-local-variable 'term-terminal-previous-parameter-3) | ||
| 2881 | (make-local-variable 'term-terminal-previous-parameter-4) | ||
| 2882 | (make-local-variable 'term-terminal-more-parameters) | ||
| 2883 | (setq term-terminal-parameter 0) | 2873 | (setq term-terminal-parameter 0) |
| 2884 | (setq term-terminal-previous-parameter -1) | 2874 | (setq term-terminal-previous-parameter -1) |
| 2885 | (setq term-terminal-previous-parameter-2 -1) | 2875 | (setq term-terminal-previous-parameter-2 -1) |
| @@ -2898,18 +2888,47 @@ See `term-prompt-regexp'." | |||
| 2898 | ;; (term-goto term-current-row 0) | 2888 | ;; (term-goto term-current-row 0) |
| 2899 | ;; (setq term-terminal-state 0)) | 2889 | ;; (setq term-terminal-state 0)) |
| 2900 | ((eq char ?M) ;; scroll reversed (terminfo: ri) | 2890 | ((eq char ?M) ;; scroll reversed (terminfo: ri) |
| 2901 | (term-down -1) | 2891 | (if (or (< (term-current-row) term-scroll-start) |
| 2892 | (>= (1- (term-current-row)) | ||
| 2893 | term-scroll-start)) | ||
| 2894 | ;; Scrolling up will not move outside | ||
| 2895 | ;; the scroll region. | ||
| 2896 | (term-down -1) | ||
| 2897 | ;; Scrolling the scroll region is needed. | ||
| 2898 | (term-down -1 t)) | ||
| 2902 | (setq term-terminal-state 0)) | 2899 | (setq term-terminal-state 0)) |
| 2903 | ((eq char ?7) ;; Save cursor (terminfo: sc) | 2900 | ((eq char ?7) ;; Save cursor (terminfo: sc) |
| 2904 | (term-handle-deferred-scroll) | 2901 | (term-handle-deferred-scroll) |
| 2905 | (setq term-saved-cursor | 2902 | (setq term-saved-cursor |
| 2906 | (cons (term-current-row) | 2903 | (list (term-current-row) |
| 2907 | (term-horizontal-column))) | 2904 | (term-horizontal-column) |
| 2905 | term-ansi-current-bg-color | ||
| 2906 | term-ansi-current-bold | ||
| 2907 | term-ansi-current-color | ||
| 2908 | term-ansi-current-invisible | ||
| 2909 | term-ansi-current-reverse | ||
| 2910 | term-ansi-current-underline | ||
| 2911 | term-current-face) | ||
| 2912 | ) | ||
| 2908 | (setq term-terminal-state 0)) | 2913 | (setq term-terminal-state 0)) |
| 2909 | ((eq char ?8) ;; Restore cursor (terminfo: rc) | 2914 | ((eq char ?8) ;; Restore cursor (terminfo: rc) |
| 2910 | (if term-saved-cursor | 2915 | (when term-saved-cursor |
| 2911 | (term-goto (car term-saved-cursor) | 2916 | (term-goto (nth 0 term-saved-cursor) |
| 2912 | (cdr term-saved-cursor))) | 2917 | (nth 1 term-saved-cursor)) |
| 2918 | (setq term-ansi-current-bg-color | ||
| 2919 | (nth 2 term-saved-cursor) | ||
| 2920 | term-ansi-current-bold | ||
| 2921 | (nth 3 term-saved-cursor) | ||
| 2922 | term-ansi-current-color | ||
| 2923 | (nth 4 term-saved-cursor) | ||
| 2924 | term-ansi-current-invisible | ||
| 2925 | (nth 5 term-saved-cursor) | ||
| 2926 | term-ansi-current-reverse | ||
| 2927 | (nth 6 term-saved-cursor) | ||
| 2928 | term-ansi-current-underline | ||
| 2929 | (nth 7 term-saved-cursor) | ||
| 2930 | term-current-face | ||
| 2931 | (nth 8 term-saved-cursor))) | ||
| 2913 | (setq term-terminal-state 0)) | 2932 | (setq term-terminal-state 0)) |
| 2914 | ((eq char ?c) ;; \Ec - Reset (terminfo: rs1) | 2933 | ((eq char ?c) ;; \Ec - Reset (terminfo: rs1) |
| 2915 | ;; This is used by the "clear" program. | 2934 | ;; This is used by the "clear" program. |
| @@ -2921,6 +2940,8 @@ See `term-prompt-regexp'." | |||
| 2921 | ;; ((eq char ?#) | 2940 | ;; ((eq char ?#) |
| 2922 | ;; (when (eq (aref str (1+ i)) ?8) | 2941 | ;; (when (eq (aref str (1+ i)) ?8) |
| 2923 | ;; (setq i (1+ i)) | 2942 | ;; (setq i (1+ i)) |
| 2943 | ;; (setq term-scroll-start 0) | ||
| 2944 | ;; (setq term-scroll-end term-height) | ||
| 2924 | ;; (setq term-terminal-state 0))) | 2945 | ;; (setq term-terminal-state 0))) |
| 2925 | ((setq term-terminal-state 0)))) | 2946 | ((setq term-terminal-state 0)))) |
| 2926 | ((eq term-terminal-state 3) ; Seen Esc [ | 2947 | ((eq term-terminal-state 3) ; Seen Esc [ |
| @@ -3048,6 +3069,8 @@ See `term-prompt-regexp'." | |||
| 3048 | (erase-buffer) | 3069 | (erase-buffer) |
| 3049 | (setq term-current-row 0) | 3070 | (setq term-current-row 0) |
| 3050 | (setq term-current-column 1) | 3071 | (setq term-current-column 1) |
| 3072 | (setq term-scroll-start 0) | ||
| 3073 | (setq term-scroll-end term-height) | ||
| 3051 | (setq term-insert-mode nil) | 3074 | (setq term-insert-mode nil) |
| 3052 | (setq term-current-face nil) | 3075 | (setq term-current-face nil) |
| 3053 | (setq term-ansi-current-underline nil) | 3076 | (setq term-ansi-current-underline nil) |
| @@ -3194,8 +3217,8 @@ See `term-prompt-regexp'." | |||
| 3194 | 3217 | ||
| 3195 | (defun term-handle-ansi-escape (proc char) | 3218 | (defun term-handle-ansi-escape (proc char) |
| 3196 | (cond | 3219 | (cond |
| 3197 | ((or (eq char ?H) ; cursor motion (terminfo: cup,home) | 3220 | ((or (eq char ?H) ;; cursor motion (terminfo: cup,home) |
| 3198 | ;; (eq char ?f) ; xterm seems to handle this sequence too, not | 3221 | ;; (eq char ?f) ;; xterm seems to handle this sequence too, not |
| 3199 | ;; needed for now | 3222 | ;; needed for now |
| 3200 | ) | 3223 | ) |
| 3201 | (if (<= term-terminal-parameter 0) | 3224 | (if (<= term-terminal-parameter 0) |
| @@ -3212,10 +3235,23 @@ See `term-prompt-regexp'." | |||
| 3212 | ;; \E[A - cursor up (terminfo: cuu, cuu1) | 3235 | ;; \E[A - cursor up (terminfo: cuu, cuu1) |
| 3213 | ((eq char ?A) | 3236 | ((eq char ?A) |
| 3214 | (term-handle-deferred-scroll) | 3237 | (term-handle-deferred-scroll) |
| 3215 | (term-down (- (max 1 term-terminal-parameter)) t)) | 3238 | (let ((tcr (term-current-row))) |
| 3239 | (term-down | ||
| 3240 | (if (< (- tcr term-terminal-parameter) term-scroll-start) | ||
| 3241 | ;; If the amount to move is before scroll start, move | ||
| 3242 | ;; to scroll start. | ||
| 3243 | (- term-scroll-start tcr) | ||
| 3244 | (if (>= term-terminal-parameter tcr) | ||
| 3245 | (- tcr) | ||
| 3246 | (- (max 1 term-terminal-parameter)))) t))) | ||
| 3216 | ;; \E[B - cursor down (terminfo: cud) | 3247 | ;; \E[B - cursor down (terminfo: cud) |
| 3217 | ((eq char ?B) | 3248 | ((eq char ?B) |
| 3218 | (term-down (max 1 term-terminal-parameter) t)) | 3249 | (let ((tcr (term-current-row))) |
| 3250 | (unless (= tcr (1- term-scroll-end)) | ||
| 3251 | (term-down | ||
| 3252 | (if (> (+ tcr term-terminal-parameter) term-scroll-end) | ||
| 3253 | (- term-scroll-end 1 tcr) | ||
| 3254 | (max 1 term-terminal-parameter)) t)))) | ||
| 3219 | ;; \E[C - cursor right (terminfo: cuf, cuf1) | 3255 | ;; \E[C - cursor right (terminfo: cuf, cuf1) |
| 3220 | ((eq char ?C) | 3256 | ((eq char ?C) |
| 3221 | (term-move-columns | 3257 | (term-move-columns |
| @@ -3264,12 +3300,12 @@ See `term-prompt-regexp'." | |||
| 3264 | ;;(terminfo: smso,rmso,smul,rmul,rev,bold,sgr0,invis,op,setab,setaf) | 3300 | ;;(terminfo: smso,rmso,smul,rmul,rev,bold,sgr0,invis,op,setab,setaf) |
| 3265 | ((eq char ?m) | 3301 | ((eq char ?m) |
| 3266 | (when (= term-terminal-more-parameters 1) | 3302 | (when (= term-terminal-more-parameters 1) |
| 3267 | (if (>= term-terminal-previous-parameter-4 0) | 3303 | (when (>= term-terminal-previous-parameter-4 0) |
| 3268 | (term-handle-colors-array term-terminal-previous-parameter-4)) | 3304 | (term-handle-colors-array term-terminal-previous-parameter-4)) |
| 3269 | (if (>= term-terminal-previous-parameter-3 0) | 3305 | (when (>= term-terminal-previous-parameter-3 0) |
| 3270 | (term-handle-colors-array term-terminal-previous-parameter-3)) | 3306 | (term-handle-colors-array term-terminal-previous-parameter-3)) |
| 3271 | (if (>= term-terminal-previous-parameter-2 0) | 3307 | (when (>= term-terminal-previous-parameter-2 0) |
| 3272 | (term-handle-colors-array term-terminal-previous-parameter-2)) | 3308 | (term-handle-colors-array term-terminal-previous-parameter-2)) |
| 3273 | (term-handle-colors-array term-terminal-previous-parameter)) | 3309 | (term-handle-colors-array term-terminal-previous-parameter)) |
| 3274 | (term-handle-colors-array term-terminal-parameter)) | 3310 | (term-handle-colors-array term-terminal-parameter)) |
| 3275 | 3311 | ||
| @@ -3280,14 +3316,14 @@ See `term-prompt-regexp'." | |||
| 3280 | (format "\e[%s;%sR" | 3316 | (format "\e[%s;%sR" |
| 3281 | (1+ (term-current-row)) | 3317 | (1+ (term-current-row)) |
| 3282 | (1+ (term-horizontal-column))))) | 3318 | (1+ (term-horizontal-column))))) |
| 3283 | ;; \E[r - Set scrolling region | 3319 | ;; \E[r - Set scrolling region (terminfo: csr) |
| 3284 | ((eq char ?r) ;; (terminfo: csr) | 3320 | ((eq char ?r) |
| 3285 | (term-scroll-region | 3321 | (term-set-scroll-region |
| 3286 | (1- term-terminal-previous-parameter) | 3322 | (1- term-terminal-previous-parameter) |
| 3287 | term-terminal-parameter)) | 3323 | term-terminal-parameter)) |
| 3288 | (t))) | 3324 | (t))) |
| 3289 | 3325 | ||
| 3290 | (defun term-scroll-region (top bottom) | 3326 | (defun term-set-scroll-region (top bottom) |
| 3291 | "Set scrolling region. | 3327 | "Set scrolling region. |
| 3292 | TOP is the top-most line (inclusive) of the new scrolling region, | 3328 | TOP is the top-most line (inclusive) of the new scrolling region, |
| 3293 | while BOTTOM is the line following the new scrolling region (e.g. exclusive). | 3329 | while BOTTOM is the line following the new scrolling region (e.g. exclusive). |
| @@ -3305,8 +3341,7 @@ The top-most line is line 0." | |||
| 3305 | (not (and (= term-scroll-start 0) | 3341 | (not (and (= term-scroll-start 0) |
| 3306 | (= term-scroll-end term-height))))) | 3342 | (= term-scroll-end term-height))))) |
| 3307 | (term-move-columns (- (term-current-column))) | 3343 | (term-move-columns (- (term-current-column))) |
| 3308 | (term-goto | 3344 | (term-goto 0 0)) |
| 3309 | term-scroll-start (term-current-column))) | ||
| 3310 | 3345 | ||
| 3311 | ;; (defun term-switch-to-alternate-sub-buffer (set) | 3346 | ;; (defun term-switch-to-alternate-sub-buffer (set) |
| 3312 | ;; ;; If asked to switch to (from) the alternate sub-buffer, and already (not) | 3347 | ;; ;; If asked to switch to (from) the alternate sub-buffer, and already (not) |
| @@ -3589,21 +3624,36 @@ all pending output has been dealt with.")) | |||
| 3589 | 3624 | ||
| 3590 | (defun term-handle-scroll (down) | 3625 | (defun term-handle-scroll (down) |
| 3591 | (let ((scroll-needed | 3626 | (let ((scroll-needed |
| 3592 | (- (+ (term-current-row) down 1) term-scroll-end))) | 3627 | (- (+ (term-current-row) down) |
| 3593 | (if (> scroll-needed 0) | 3628 | (if (< down 0) term-scroll-start term-scroll-end)))) |
| 3629 | (if (or (and (< down 0) (< scroll-needed 0)) | ||
| 3630 | (and (> down 0) (> scroll-needed 0))) | ||
| 3594 | (let ((save-point (copy-marker (point))) (save-top)) | 3631 | (let ((save-point (copy-marker (point))) (save-top)) |
| 3595 | (goto-char term-home-marker) | 3632 | (goto-char term-home-marker) |
| 3596 | (cond (term-scroll-with-delete | 3633 | (cond (term-scroll-with-delete |
| 3597 | ;; delete scroll-needed lines at term-scroll-start | 3634 | (if (< down 0) |
| 3598 | (term-vertical-motion term-scroll-start) | 3635 | (progn |
| 3599 | (setq save-top (point)) | 3636 | ;; Delete scroll-needed lines at term-scroll-end, |
| 3600 | (term-vertical-motion scroll-needed) | 3637 | ;; then insert scroll-needed lines. |
| 3601 | (delete-region save-top (point)) | 3638 | (term-vertical-motion (1- term-scroll-end)) |
| 3602 | (goto-char save-point) | 3639 | (end-of-line) |
| 3603 | (term-vertical-motion down) | 3640 | (setq save-top (point)) |
| 3604 | (term-adjust-current-row-cache (- scroll-needed)) | 3641 | (term-vertical-motion scroll-needed) |
| 3642 | (end-of-line) | ||
| 3643 | (delete-region save-top (point)) | ||
| 3644 | (goto-char save-point) | ||
| 3645 | (setq down (- scroll-needed down)) | ||
| 3646 | (term-vertical-motion down)) | ||
| 3647 | ;; Delete scroll-needed lines at term-scroll-start. | ||
| 3648 | (term-vertical-motion term-scroll-start) | ||
| 3649 | (setq save-top (point)) | ||
| 3650 | (term-vertical-motion scroll-needed) | ||
| 3651 | (delete-region save-top (point)) | ||
| 3652 | (goto-char save-point) | ||
| 3653 | (term-vertical-motion down) | ||
| 3654 | (term-adjust-current-row-cache (- scroll-needed))) | ||
| 3605 | (setq term-current-column nil) | 3655 | (setq term-current-column nil) |
| 3606 | (term-insert-char ?\n scroll-needed)) | 3656 | (term-insert-char ?\n (abs scroll-needed))) |
| 3607 | ((and (numberp term-pager-count) | 3657 | ((and (numberp term-pager-count) |
| 3608 | (< (setq term-pager-count (- term-pager-count down)) | 3658 | (< (setq term-pager-count (- term-pager-count down)) |
| 3609 | 0)) | 3659 | 0)) |
| @@ -3626,7 +3676,7 @@ all pending output has been dealt with.")) | |||
| 3626 | (term-adjust-current-row-cache down) | 3676 | (term-adjust-current-row-cache down) |
| 3627 | (when (or (/= (point) (point-max)) (< down 0)) | 3677 | (when (or (/= (point) (point-max)) (< down 0)) |
| 3628 | (setq down (- down (term-vertical-motion down))))) | 3678 | (setq down (- down (term-vertical-motion down))))) |
| 3629 | (cond ((> down 0) | 3679 | (cond ((>= down 0) |
| 3630 | ;; Extend buffer with extra blank lines if needed. | 3680 | ;; Extend buffer with extra blank lines if needed. |
| 3631 | (term-insert-char ?\n down) | 3681 | (term-insert-char ?\n down) |
| 3632 | (setq term-current-column 0) | 3682 | (setq term-current-column 0) |
| @@ -3714,22 +3764,22 @@ Should only be called when point is at the start of a screen line." | |||
| 3714 | ;;; at the end of this screen line to make room. | 3764 | ;;; at the end of this screen line to make room. |
| 3715 | 3765 | ||
| 3716 | (defun term-insert-spaces (count) | 3766 | (defun term-insert-spaces (count) |
| 3717 | (let ((save-point (point)) (save-eol) (point-at-eol)) | 3767 | (let ((save-point (point)) (save-eol) (pnt-at-eol)) |
| 3718 | (term-vertical-motion 1) | 3768 | (term-vertical-motion 1) |
| 3719 | (if (bolp) | 3769 | (when (bolp) |
| 3720 | (backward-char)) | 3770 | (backward-char)) |
| 3721 | (setq save-eol (point)) | 3771 | (setq save-eol (point)) |
| 3722 | (save-excursion | 3772 | (save-excursion |
| 3723 | (end-of-line) | 3773 | (end-of-line) |
| 3724 | (setq point-at-eol (point))) | 3774 | (setq pnt-at-eol (point))) |
| 3725 | (move-to-column (+ (term-start-line-column) (- term-width count)) t) | 3775 | (move-to-column (+ (term-start-line-column) (- term-width count)) t) |
| 3726 | ;; If move-to-column extends the current line it will use the face | 3776 | ;; If move-to-column extends the current line it will use the face |
| 3727 | ;; from the last character on the line, set the face for the chars | 3777 | ;; from the last character on the line, set the face for the chars |
| 3728 | ;; to default. | 3778 | ;; to default. |
| 3729 | (when (> (point) (point-at-eol)) | 3779 | (when (>= (point) pnt-at-eol) |
| 3730 | (put-text-property point-at-eol (point) 'face 'default)) | 3780 | (put-text-property pnt-at-eol (point) 'face 'default)) |
| 3731 | (if (> save-eol (point)) | 3781 | (when (> save-eol (point)) |
| 3732 | (delete-region (point) save-eol)) | 3782 | (delete-region (point) save-eol)) |
| 3733 | (goto-char save-point) | 3783 | (goto-char save-point) |
| 3734 | (term-insert-char ? count) | 3784 | (term-insert-char ? count) |
| 3735 | (goto-char save-point))) | 3785 | (goto-char save-point))) |
| @@ -3739,6 +3789,8 @@ Should only be called when point is at the start of a screen line." | |||
| 3739 | (save-current-column term-current-column) | 3789 | (save-current-column term-current-column) |
| 3740 | (save-start-line-column term-start-line-column) | 3790 | (save-start-line-column term-start-line-column) |
| 3741 | (save-current-row (term-current-row))) | 3791 | (save-current-row (term-current-row))) |
| 3792 | (when (>= (+ save-current-row lines) term-scroll-end) | ||
| 3793 | (setq lines (- lines (- (+ save-current-row lines) term-scroll-end)))) | ||
| 3742 | (term-down lines) | 3794 | (term-down lines) |
| 3743 | (delete-region start (point)) | 3795 | (delete-region start (point)) |
| 3744 | (term-down (- term-scroll-end save-current-row lines)) | 3796 | (term-down (- term-scroll-end save-current-row lines)) |
| @@ -3754,7 +3806,17 @@ Should only be called when point is at the start of a screen line." | |||
| 3754 | (save-current-column term-current-column) | 3806 | (save-current-column term-current-column) |
| 3755 | (save-start-line-column term-start-line-column) | 3807 | (save-start-line-column term-start-line-column) |
| 3756 | (save-current-row (term-current-row))) | 3808 | (save-current-row (term-current-row))) |
| 3757 | (term-down (- term-scroll-end save-current-row lines)) | 3809 | ;; Inserting lines should take into account the scroll region. |
| 3810 | (if (< save-current-row term-scroll-start) | ||
| 3811 | ;; If point is before scroll start, | ||
| 3812 | (progn | ||
| 3813 | (setq lines (- lines (- term-scroll-start save-current-row))) | ||
| 3814 | (term-down (- term-scroll-start save-current-row)) | ||
| 3815 | (setq start (point))) | ||
| 3816 | ;; The number of inserted lines shouldn't exceed the scroll region end. | ||
| 3817 | (when (>= (+ save-current-row lines) term-scroll-end) | ||
| 3818 | (setq lines (- lines (- (+ save-current-row lines) term-scroll-end)))) | ||
| 3819 | (term-down (- term-scroll-end save-current-row lines))) | ||
| 3758 | (setq start-deleted (point)) | 3820 | (setq start-deleted (point)) |
| 3759 | (term-down lines) | 3821 | (term-down lines) |
| 3760 | (delete-region start-deleted (point)) | 3822 | (delete-region start-deleted (point)) |