Function: term--color-as-hex

term--color-as-hex is a byte-compiled function defined in term.el.gz.

Signature

(term--color-as-hex FOR-FOREGROUND)

Documentation

Return the current ANSI color as a hexadecimal color string.

Use the current background color if FOR-FOREGROUND is nil, otherwise use the current foreground color. Return nil if the color is unset in the terminal state.

Source Code

;; Defined in /usr/src/emacs/lisp/term.el.gz
(defun term--color-as-hex (for-foreground)
  "Return the current ANSI color as a hexadecimal color string.
Use the current background color if FOR-FOREGROUND is nil,
otherwise use the current foreground color.  Return nil if the
color is unset in the terminal state."
  (let ((color (if for-foreground term-ansi-current-color
                 term-ansi-current-bg-color)))
    (when color
      (or (ansi-color--code-as-hex (1- color))
          (progn
            (and ansi-color-bold-is-bright term-ansi-current-bold
                 (<= 1 color 8)
                 (setq color (+ color 8)))
            (if for-foreground
                (face-foreground (elt ansi-term-color-vector color)
                                 nil 'default)
              (face-background (elt ansi-term-color-vector color)
                               nil 'default)))))))