1221 |
;; Which would be better: "\e[A" or "\eOA"? readline accepts either. |
;; Which would be better: "\e[A" or "\eOA"? readline accepts either. |
1222 |
;; For my configuration it's definitely better \eOA but YMMV. -mm |
;; For my configuration it's definitely better \eOA but YMMV. -mm |
1223 |
;; For example: vi works with \eOA while elm wants \e[A ... |
;; For example: vi works with \eOA while elm wants \e[A ... |
1224 |
|
;;; (terminfo: kcuu1, kcud1, kcuf1, kcub1, khome, kend, kpp, knp, kdch1, kbs) |
1225 |
(defun term-send-up () (interactive) (term-send-raw-string "\eOA")) |
(defun term-send-up () (interactive) (term-send-raw-string "\eOA")) |
1226 |
(defun term-send-down () (interactive) (term-send-raw-string "\eOB")) |
(defun term-send-down () (interactive) (term-send-raw-string "\eOB")) |
1227 |
(defun term-send-right () (interactive) (term-send-raw-string "\eOC")) |
(defun term-send-right () (interactive) (term-send-raw-string "\eOC")) |
2820 |
(1- (- term-width (term-current-column))))) |
(1- (- term-width (term-current-column))))) |
2821 |
(when (= term-width (term-current-column)) |
(when (= term-width (term-current-column)) |
2822 |
(term-move-columns -1)))) |
(term-move-columns -1)))) |
2823 |
((eq char ?\r) |
((eq char ?\r) ;; (terminfo: cr) |
2824 |
;; Optimize CRLF at end of buffer: |
;; Optimize CRLF at end of buffer: |
2825 |
(cond ((and (< (setq temp (1+ i)) str-length) |
(cond ((and (< (setq temp (1+ i)) str-length) |
2826 |
(eq (aref str temp) ?\n) |
(eq (aref str temp) ?\n) |
2836 |
(t ;; Not followed by LF or can't optimize: |
(t ;; Not followed by LF or can't optimize: |
2837 |
(term-vertical-motion 0) |
(term-vertical-motion 0) |
2838 |
(setq term-current-column term-start-line-column)))) |
(setq term-current-column term-start-line-column)))) |
2839 |
((eq char ?\n) |
((eq char ?\n) ;; (terminfo: cud1, ind) |
2840 |
(if (not (and term-kill-echo-list |
(if (not (and term-kill-echo-list |
2841 |
(term-check-kill-echo-list))) |
(term-check-kill-echo-list))) |
2842 |
(term-down 1 t))) |
(term-down 1 t))) |
2847 |
((eq char 0)) ; NUL: Do nothing |
((eq char 0)) ; NUL: Do nothing |
2848 |
((eq char ?\016)) ; Shift Out - ignored |
((eq char ?\016)) ; Shift Out - ignored |
2849 |
((eq char ?\017)) ; Shift In - ignored |
((eq char ?\017)) ; Shift In - ignored |
2850 |
((eq char ?\^G) |
((eq char ?\^G) ;; (terminfo: bel) |
2851 |
(beep t)) ; Bell |
(beep t)) |
2852 |
((eq char ?\032) |
((eq char ?\032) |
2853 |
(let ((end (string-match "\r?$" str i))) |
(let ((end (string-match "\r?$" str i))) |
2854 |
(if end |
(if end |
2855 |
(funcall term-command-hook |
(funcall term-command-hook |
2856 |
(prog1 (substring str (1+ i) end) |
(prog1 (substring str (1+ i) end) |
2857 |
(setq i (match-end 0)))) |
(setq i (match-end 0)))) |
2858 |
(setq term-terminal-parameter |
(setq term-terminal-parameter (substring str i)) |
|
(substring str i)) |
|
2859 |
(setq term-terminal-state 4) |
(setq term-terminal-state 4) |
2860 |
(setq i str-length)))) |
(setq i str-length)))) |
2861 |
(t ; insert char FIXME: Should never happen |
(t ; insert char FIXME: Should never happen |
3072 |
((eq parameter 5) |
((eq parameter 5) |
3073 |
(setq term-ansi-current-bold t)) |
(setq term-ansi-current-bold t)) |
3074 |
|
|
3075 |
;;; Reverse |
;;; Reverse (terminfo: smso) |
3076 |
((eq parameter 7) |
((eq parameter 7) |
3077 |
(setq term-ansi-current-reverse t)) |
(setq term-ansi-current-reverse t)) |
3078 |
|
|
3080 |
((eq parameter 8) |
((eq parameter 8) |
3081 |
(setq term-ansi-current-invisible t)) |
(setq term-ansi-current-invisible t)) |
3082 |
|
|
3083 |
;;; Reset underline (i.e. terminfo rmul) |
;;; Reset underline (terminfo: rmul) |
3084 |
((eq parameter 24) |
((eq parameter 24) |
3085 |
(setq term-ansi-current-underline nil)) |
(setq term-ansi-current-underline nil)) |
3086 |
|
|
3087 |
;;; Reset reverse (i.e. terminfo rmso) |
;;; Reset reverse (terminfo: rmso) |
3088 |
((eq parameter 27) |
((eq parameter 27) |
3089 |
(setq term-ansi-current-reverse nil)) |
(setq term-ansi-current-reverse nil)) |
3090 |
|
|
3189 |
|
|
3190 |
(defun term-handle-ansi-escape (proc char) |
(defun term-handle-ansi-escape (proc char) |
3191 |
(cond |
(cond |
3192 |
((or (eq char ?H) ; cursor motion (terminfo: cup) |
((or (eq char ?H) ; cursor motion (terminfo: cup,home) |
3193 |
;; (eq char ?f) ; xterm seems to handle this sequence too, not |
;; (eq char ?f) ; xterm seems to handle this sequence too, not |
3194 |
;; needed for now |
;; needed for now |
3195 |
) |
) |
3211 |
;; \E[B - cursor down (terminfo: cud) |
;; \E[B - cursor down (terminfo: cud) |
3212 |
((eq char ?B) |
((eq char ?B) |
3213 |
(term-down (max 1 term-terminal-parameter) t)) |
(term-down (max 1 term-terminal-parameter) t)) |
3214 |
;; \E[C - cursor right (terminfo: cuf) |
;; \E[C - cursor right (terminfo: cuf, cuf1) |
3215 |
((eq char ?C) |
((eq char ?C) |
3216 |
(term-move-columns |
(term-move-columns |
3217 |
(max 1 |
(max 1 |
3230 |
;; \E[L - insert lines (terminfo: il, il1) |
;; \E[L - insert lines (terminfo: il, il1) |
3231 |
((eq char ?L) |
((eq char ?L) |
3232 |
(term-insert-lines (max 1 term-terminal-parameter))) |
(term-insert-lines (max 1 term-terminal-parameter))) |
3233 |
;; \E[M - delete lines |
;; \E[M - delete lines (terminfo: dl, dl1) |
3234 |
((eq char ?M) |
((eq char ?M) |
3235 |
(term-delete-lines (max 1 term-terminal-parameter))) |
(term-delete-lines (max 1 term-terminal-parameter))) |
3236 |
;; \E[P - delete chars |
;; \E[P - delete chars (terminfo: dch, dch1) |
3237 |
((eq char ?P) |
((eq char ?P) |
3238 |
(term-delete-chars (max 1 term-terminal-parameter))) |
(term-delete-chars (max 1 term-terminal-parameter))) |
3239 |
;; \E[@ - insert spaces |
;; \E[@ - insert spaces (terminfo: ich) |
3240 |
((eq char ?@) ;; (terminfo: ich) |
((eq char ?@) |
3241 |
(term-insert-spaces (max 1 term-terminal-parameter))) |
(term-insert-spaces (max 1 term-terminal-parameter))) |
3242 |
;; \E[?h - DEC Private Mode Set |
;; \E[?h - DEC Private Mode Set |
3243 |
((eq char ?h) |
((eq char ?h) |