Mercurial > emacs
comparison lisp/term/xterm.el @ 106973:9b98e092d459
(xterm-maybe-set-dark-background-mode): Rename
from xterm-set-background-mode. Return t if the background mode
was set.
(terminal-init-xterm): Move tty-set-up-initial-frame-faces
earlier, call it again in case the background mode has changed.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sun, 24 Jan 2010 13:08:53 -0800 |
parents | 1d1d5d9bd884 |
children | 8839cd62c3d2 |
comparison
equal
deleted
inserted
replaced
106971:9fa45b0cc7d9 | 106973:9b98e092d459 |
---|---|
460 ;; made in the .emacs file. | 460 ;; made in the .emacs file. |
461 (set-keymap-parent map (keymap-parent input-decode-map)) | 461 (set-keymap-parent map (keymap-parent input-decode-map)) |
462 (set-keymap-parent input-decode-map map))) | 462 (set-keymap-parent input-decode-map map))) |
463 | 463 |
464 (xterm-register-default-colors) | 464 (xterm-register-default-colors) |
465 (tty-set-up-initial-frame-faces) | |
465 | 466 |
466 ;; Try to turn on the modifyOtherKeys feature on modern xterms. | 467 ;; Try to turn on the modifyOtherKeys feature on modern xterms. |
467 ;; When it is turned on many more key bindings work: things like | 468 ;; When it is turned on many more key bindings work: things like |
468 ;; C-. C-, etc. | 469 ;; C-. C-, etc. |
469 ;; To do that we need to find out if the current terminal supports | 470 ;; To do that we need to find out if the current terminal supports |
470 ;; modifyOtherKeys. At this time only xterm does. | 471 ;; modifyOtherKeys. At this time only xterm does. |
471 (let ((coding-system-for-read 'binary) | 472 (let ((coding-system-for-read 'binary) |
472 (chr nil) | 473 (chr nil) |
473 (str nil) | 474 (str nil) |
475 (recompute-faces nil) | |
474 version) | 476 version) |
475 ;; Pending input can be mistakenly returned by the calls to | 477 ;; Pending input can be mistakenly returned by the calls to |
476 ;; read-event below. Discard it. | 478 ;; read-event below. Discard it. |
477 (discard-input) | 479 (discard-input) |
478 ;; Try to find out the type of terminal by sending a "Secondary | 480 ;; Try to find out the type of terminal by sending a "Secondary |
500 (when (equal (read-event nil nil 2) ?\]) | 502 (when (equal (read-event nil nil 2) ?\]) |
501 (setq str "") | 503 (setq str "") |
502 (while (not (equal (setq chr (read-event nil nil 2)) ?\\)) | 504 (while (not (equal (setq chr (read-event nil nil 2)) ?\\)) |
503 (setq str (concat str (string chr)))) | 505 (setq str (concat str (string chr)))) |
504 (when (string-match "11;rgb:\\([a-f0-9]+\\)/\\([a-f0-9]+\\)/\\([a-f0-9]+\\)" str) | 506 (when (string-match "11;rgb:\\([a-f0-9]+\\)/\\([a-f0-9]+\\)/\\([a-f0-9]+\\)" str) |
505 (xterm-set-background-mode | 507 (setq recompute-faces |
506 (string-to-number (match-string 1 str) 16) | 508 (xterm-maybe-set-dark-background-mode |
507 (string-to-number (match-string 2 str) 16) | 509 (string-to-number (match-string 1 str) 16) |
508 (string-to-number (match-string 3 str) 16)))))) | 510 (string-to-number (match-string 2 str) 16) |
511 (string-to-number (match-string 3 str) 16))))))) | |
509 ;; NUMBER2 is the xterm version number, look for something | 512 ;; NUMBER2 is the xterm version number, look for something |
510 ;; greater than 216, the version when modifyOtherKeys was | 513 ;; greater than 216, the version when modifyOtherKeys was |
511 ;; introduced. | 514 ;; introduced. |
512 (when (>= version 216) | 515 (when (>= version 216) |
513 ;; Make sure that the modifyOtherKeys state is restored when | 516 ;; Make sure that the modifyOtherKeys state is restored when |
518 (add-hook 'delete-terminal-functions 'xterm-remove-modify-other-keys) | 521 (add-hook 'delete-terminal-functions 'xterm-remove-modify-other-keys) |
519 ;; Add the selected frame to the list of frames that | 522 ;; Add the selected frame to the list of frames that |
520 ;; need to deal with modify-other-keys. | 523 ;; need to deal with modify-other-keys. |
521 (push (frame-terminal (selected-frame)) | 524 (push (frame-terminal (selected-frame)) |
522 xterm-modify-other-keys-terminal-list) | 525 xterm-modify-other-keys-terminal-list) |
523 (xterm-turn-on-modify-other-keys)))))) | 526 (xterm-turn-on-modify-other-keys)) |
524 | 527 |
525 ;; This recomputes all the default faces given the colors we've just set up. | 528 ;; Recompute faces here in case the background mode was |
526 (tty-set-up-initial-frame-faces) | 529 ;; set to dark. We used to call |
530 ;; `tty-set-up-initial-frame-faces' only once, but that | |
531 ;; caused the light background faces to be computed | |
532 ;; incorrectly. See: | |
533 ;; http://permalink.gmane.org/gmane.emacs.devel/119627 | |
534 (when recompute-faces | |
535 (tty-set-up-initial-frame-faces)))))) | |
527 | 536 |
528 (run-hooks 'terminal-init-xterm-hook)) | 537 (run-hooks 'terminal-init-xterm-hook)) |
529 | 538 |
530 ;; Set up colors, for those versions of xterm that support it. | 539 ;; Set up colors, for those versions of xterm that support it. |
531 (defvar xterm-standard-colors | 540 (defvar xterm-standard-colors |
664 (memq terminal xterm-modify-other-keys-terminal-list)) | 673 (memq terminal xterm-modify-other-keys-terminal-list)) |
665 (setq xterm-modify-other-keys-terminal-list | 674 (setq xterm-modify-other-keys-terminal-list |
666 (delq terminal xterm-modify-other-keys-terminal-list)) | 675 (delq terminal xterm-modify-other-keys-terminal-list)) |
667 (send-string-to-terminal "\e[>4m" terminal))) | 676 (send-string-to-terminal "\e[>4m" terminal))) |
668 | 677 |
669 (defun xterm-set-background-mode (redc greenc bluec) | 678 (defun xterm-maybe-set-dark-background-mode (redc greenc bluec) |
670 ;; Use the heuristic in `frame-set-background-mode' to decide if a | 679 ;; Use the heuristic in `frame-set-background-mode' to decide if a |
671 ;; frame is dark. | 680 ;; frame is dark. |
672 (when (< (+ redc greenc bluec) (* .6 (+ 65535 65535 65535))) | 681 (when (< (+ redc greenc bluec) (* .6 (+ 65535 65535 65535))) |
673 (set-terminal-parameter nil 'background-mode 'dark))) | 682 (setq xterm-background-mode-changed t) |
683 (set-terminal-parameter nil 'background-mode 'dark) | |
684 t)) | |
674 | 685 |
675 ;; arch-tag: 12e7ebdd-1e6c-4b25-b0f9-35ace25e855a | 686 ;; arch-tag: 12e7ebdd-1e6c-4b25-b0f9-35ace25e855a |
676 ;;; xterm.el ends here | 687 ;;; xterm.el ends here |