Function: term--handle-colors-list
term--handle-colors-list is a byte-compiled function defined in
term.el.gz.
Signature
(term--handle-colors-list PARAMETERS)
Source Code
;; Defined in /usr/src/emacs/lisp/term.el.gz
(defun term--handle-colors-list (parameters)
(while parameters
(pcase (pop parameters)
(1 (setq term-ansi-current-bold t)) ; (terminfo: bold)
(2 (setq term-ansi-current-faint t)) ; (terminfo: dim)
(3 (setq term-ansi-current-italic t)) ; (terminfo: sitm)
(4 (setq term-ansi-current-underline t)) ; (terminfo: smul)
(5 (setq term-ansi-current-slow-blink t)) ; (terminfo: blink)
(6 (setq term-ansi-current-fast-blink t))
(7 (setq term-ansi-current-reverse t)) ; (terminfo: smso, rev)
(8 (setq term-ansi-current-invisible t)) ; (terminfo: invis)
(21 (setq term-ansi-current-bold nil))
(22 (setq term-ansi-current-bold nil)
(setq term-ansi-current-faint nil))
(23 (setq term-ansi-current-italic nil)) ; (terminfo: ritm)
(24 (setq term-ansi-current-underline nil)) ; (terminfo: rmul)
(25 (setq term-ansi-current-slow-blink nil)
(setq term-ansi-current-fast-blink nil))
(27 (setq term-ansi-current-reverse nil)) ; (terminfo: rmso)
;; Foreground (terminfo: setaf)
((and param (guard (<= 30 param 37)))
(setq term-ansi-current-color (- param 29)))
;; Bright foreground (terminfo: setaf)
((and param (guard (<= 90 param 97)))
(setq term-ansi-current-color (- param 81)))
;; Extended foreground (terminfo: setaf)
(38
(pcase (pop parameters)
;; 256 color
(5 (if (setq term-ansi-current-color (pop parameters))
(cl-incf term-ansi-current-color)
(term-ansi-reset)))
;; Full 24-bit color
(2 (cl-loop with color = (1+ 256) ; Base
for i from 16 downto 0 by 8
if (pop parameters)
do (setq color (+ color (ash it i)))
else return (term-ansi-reset)
finally
(if (> color (+ 1 256 #xFFFFFF))
(term-ansi-reset)
(setq term-ansi-current-color color))))
(_ (term-ansi-reset))))
;; Reset foreground (terminfo: op)
(39 (setq term-ansi-current-color 0))
;; Background (terminfo: setab)
((and param (guard (<= 40 param 47)))
(setq term-ansi-current-bg-color (- param 39)))
;; Bright background (terminfo: setab)
((and param (guard (<= 100 param 107)))
(setq term-ansi-current-bg-color (- param 91)))
;; Extended background (terminfo: setab)
(48
(pcase (pop parameters)
;; 256 color
(5 (if (setq term-ansi-current-bg-color (pop parameters))
(cl-incf term-ansi-current-bg-color)
(term-ansi-reset)))
;; Full 24-bit color
(2 (cl-loop with color = (1+ 256) ; Base
for i from 16 downto 0 by 8
if (pop parameters)
do (setq color (+ color (ash it i)))
else return (term-ansi-reset)
finally
(if (> color (+ 1 256 #xFFFFFF))
(term-ansi-reset)
(setq term-ansi-current-bg-color color))))
(_ (term-ansi-reset))))
;; Reset background (terminfo: op)
(49 (setq term-ansi-current-bg-color 0))
;; 0 (Reset) (terminfo: sgr0) or unknown (reset anyway)
(_ (term-ansi-reset))))
(let (fg bg)
(if term-ansi-current-invisible
(setq bg (term--color-as-hex term-ansi-current-reverse)
fg bg)
(setq fg (term--color-as-hex t)
bg (term--color-as-hex nil)))
(setq term-current-face
`( :foreground ,fg
:background ,bg
,@(unless term-ansi-current-invisible
(list :inverse-video term-ansi-current-reverse)))))
(setq term-current-face
`(,term-current-face
,@(when term-ansi-current-bold
'(term-bold))
,@(when term-ansi-current-faint
'(term-faint))
,@(when term-ansi-current-italic
'(term-italic))
,@(when term-ansi-current-underline
'(term-underline))
,@(when term-ansi-current-slow-blink
'(term-slow-blink))
,@(when term-ansi-current-fast-blink
'(term-fast-blink)))))