Function: w32-tty-setup-colors

w32-tty-setup-colors is a byte-compiled function defined in w32console.el.gz.

Signature

(w32-tty-setup-colors)

Documentation

Set up color definitions and frame parameters for w32 tty display.

Source Code

;; Defined in /usr/src/emacs/lisp/term/w32console.el.gz
;; Called from tty-set-up-initial-frame-faces in faces.el
(defun w32-tty-setup-colors ()
  "Set up color definitions and frame parameters for w32 tty display."
  (tty-color-clear)
  (let ((ncolors (display-color-cells))
        (vtp (w32-use-virtual-terminal-p)))
    (w32-tty-set-base-colors vtp)
    (if vtp
        (cond ((= ncolors 16777216) (w32-tty-define-24bit-colors))
              ((= ncolors 256)      (w32-tty-define-8bit-colors))
              (t                    (w32-tty-define-base-colors)))
      (w32-tty-define-base-colors))
    (clear-face-cache)
    (let* ((screen-color (get-screen-color vtp))
           (fg (car  screen-color))
           (bg (cadr screen-color))
           (bootstrap (and vtp (= ncolors 16777216)
                           (< fg 16) (< bg 16) (not (= 0 fg bg))))
           (fallback  (and vtp (< ncolors 16777216)
                           (or (< ncolors fg) (< ncolors bg))))
           (screen-color (if fallback (get-screen-color t) screen-color))
           (fg (if bootstrap (w32-tty-get-pixel fg) (car  screen-color)))
           (bg (if bootstrap (w32-tty-get-pixel bg) (cadr screen-color)))
           (bg-col (tty-color-by-index bg))
           (bg-dark (< (+ (nth 2 bg-col) (nth 3 bg-col) (nth 4 bg-col))
                       (* .6 (+ 65535 65535 65535))))
           (bg-mode (if bg-dark 'dark 'light)))
      (set-terminal-parameter nil 'background-mode bg-mode)
      (when (or bootstrap fallback)
        (set-screen-color fg bg t)))))