Function: term-handle-colors-array
term-handle-colors-array is a byte-compiled function defined in
term.el.gz.
Signature
(term-handle-colors-array PARAMETER)
Source Code
;; Defined in /usr/src/emacs/lisp/term.el.gz
;; New function to deal with ansi colorized output, as you can see you can
;; have any bold/underline/fg/bg/reverse combination. -mm
(defun term-handle-colors-array (parameter)
(cond
;; Bold (terminfo: bold)
((eq parameter 1)
(setq term-ansi-current-bold t))
;; Underline
((eq parameter 4)
(setq term-ansi-current-underline t))
;; Blink (unsupported by Emacs), will be translated to bold.
;; This may change in the future though.
((eq parameter 5)
(setq term-ansi-current-bold t))
;; Reverse (terminfo: smso)
((eq parameter 7)
(setq term-ansi-current-reverse t))
;; Invisible
((eq parameter 8)
(setq term-ansi-current-invisible t))
;; Reset underline (terminfo: rmul)
((eq parameter 24)
(setq term-ansi-current-underline nil))
;; Reset reverse (terminfo: rmso)
((eq parameter 27)
(setq term-ansi-current-reverse nil))
;; Foreground
((and (>= parameter 30) (<= parameter 37))
(setq term-ansi-current-color (- parameter 29)))
;; Bright foreground
((and (>= parameter 90) (<= parameter 97))
(setq term-ansi-current-color (- parameter 81)))
;; Reset foreground
((eq parameter 39)
(setq term-ansi-current-color 0))
;; Background
((and (>= parameter 40) (<= parameter 47))
(setq term-ansi-current-bg-color (- parameter 39)))
;; Bright foreground
((and (>= parameter 100) (<= parameter 107))
(setq term-ansi-current-bg-color (- parameter 91)))
;; Reset background
((eq parameter 49)
(setq term-ansi-current-bg-color 0))
;; 0 (Reset) or unknown (reset anyway)
(t
(term-ansi-reset)))
;; (message "Debug: U-%d R-%d B-%d I-%d D-%d F-%d B-%d"
;; term-ansi-current-underline
;; term-ansi-current-reverse
;; term-ansi-current-bold
;; term-ansi-current-invisible
;; term-ansi-face-already-done
;; term-ansi-current-color
;; term-ansi-current-bg-color)
(unless term-ansi-face-already-done
(let ((current-color (term--maybe-brighten-color
term-ansi-current-color
term-ansi-current-bold))
(current-bg-color (term--maybe-brighten-color
term-ansi-current-bg-color
term-ansi-current-bold)))
(if term-ansi-current-invisible
(let ((color
(if term-ansi-current-reverse
(face-foreground
(elt ansi-term-color-vector current-color)
nil 'default)
(face-background
(elt ansi-term-color-vector current-bg-color)
nil 'default))))
(setq term-current-face
(list :background color
:foreground color))
) ;; No need to bother with anything else if it's invisible.
(setq term-current-face
(list :foreground
(face-foreground
(elt ansi-term-color-vector current-color)
nil 'default)
:background
(face-background
(elt ansi-term-color-vector current-bg-color)
nil 'default)
:inverse-video term-ansi-current-reverse))
(when term-ansi-current-bold
(setq term-current-face
`(,term-current-face :inherit term-bold)))
(when term-ansi-current-underline
(setq term-current-face
`(,term-current-face :inherit term-underline))))))
;; (message "Debug %S" term-current-face)
;; FIXME: shouldn't we set term-ansi-face-already-done to t here? --Stef
(setq term-ansi-face-already-done nil))