;;; w32console.el -- Setup w32 console keys and colors.
-;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2013 Free Software Foundation, Inc.
;; Author: FSF
;; Keywords: terminals
("white" 15 65535 65535 65535))
"A list of VGA console colors, their indices and 16-bit RGB values.")
+(declare-function x-setup-function-keys "term/common-win" (frame))
+(declare-function get-screen-color "w32console.c" ())
+
(defun terminal-init-w32console ()
"Terminal initialization function for w32 console."
;; Share function key initialization with w32 gui frames
(x-setup-function-keys (selected-frame))
+ ;; Set terminal and keyboard encodings to the current OEM codepage.
+ (let ((oem-code-page-coding
+ (intern (format "cp%d" (w32-get-console-codepage))))
+ (oem-code-page-output-coding
+ (intern (format "cp%d" (w32-get-console-output-codepage))))
+ oem-cs-p oem-o-cs-p)
+ (setq oem-cs-p (coding-system-p oem-code-page-coding))
+ (setq oem-o-cs-p (coding-system-p oem-code-page-output-coding))
+ (when oem-cs-p
+ (set-keyboard-coding-system oem-code-page-coding)
+ (set-terminal-coding-system
+ (if oem-o-cs-p oem-code-page-output-coding oem-code-page-coding))))
(let* ((colors w32-tty-standard-colors)
(color (car colors)))
(tty-color-clear)
(setq colors (cdr colors)
color (car colors))))
(clear-face-cache)
+ ;; Figure out what are the colors of the console window, and set up
+ ;; the background-mode correspondingly.
+ (let* ((screen-color (get-screen-color))
+ (bg (cadr screen-color))
+ (descr (tty-color-by-index bg))
+ r g b bg-mode)
+ (setq r (nth 2 descr)
+ g (nth 3 descr)
+ b (nth 4 descr))
+ (if (< (+ r g b) (* .6 (+ 65535 65535 65535)))
+ (setq bg-mode 'dark)
+ (setq bg-mode 'light))
+ (set-terminal-parameter nil 'background-mode bg-mode))
(tty-set-up-initial-frame-faces)
(run-hooks 'terminal-init-w32-hook))
-;; arch-tag: 3195fd5e-ab86-4a46-b1dc-4f7a8c8deff3
+;;; w32console.el ends here