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 |
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) |
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 (terminfo: ht) |
(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) |
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 (terminfo: sc) |
((eq char ?7) ;; Save cursor (terminfo: sc) |
2884 |
(term-handle-deferred-scroll) |
(term-handle-deferred-scroll) |
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)) |
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) |
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 (terminfo: cuu1) |
;; \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 (terminfo: ed, clear) |
;; \E[J - clear to end of screen (terminfo: ed, clear) |
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)) |
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 |
|
(term-goto |
3269 |
|
term-scroll-start (term-current-column))) |
3270 |
|
|
3271 |
;; (defun term-switch-to-alternate-sub-buffer (set) |
;; (defun term-switch-to-alternate-sub-buffer (set) |
3272 |
;; ;; If asked to switch to (from) the alternate sub-buffer, and already (not) |
;; ;; If asked to switch to (from) the alternate sub-buffer, and already (not) |
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))))) |