Mercurial > emacs
diff lisp/faces.el @ 83074:34a7a8f40548
Fix background-mode on terminal frames (Dan Nicolaescu).
lisp/faces.el (frame-set-background-mode): Guess the background mode
on terminal frames from the termcap type string.
(tty-create-frame-with-faces): Switch to the new frame during its setup.
Load the customization library corresponding to the terminal type of the
newly created frame. (Reported by Dan Nicolaescu <dann at ics dot uci dot edu>.)
lisp/startup.el (normal-top-level): Moved background-mode heuristic to
frame-set-background-mode.
src/dispnew.c (init_display): Update the tty-type frame parameter of
the initial terminal frame.
src/frame.h (Qtty, Qtty_type): New externs.
src/term.c (term_init): Update comments.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-114
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Thu, 11 Mar 2004 01:11:38 +0000 |
parents | b44978264e1d |
children | 0d3eea319893 |
line wrap: on
line diff
--- a/lisp/faces.el Mon Mar 08 13:39:35 2004 +0000 +++ b/lisp/faces.el Thu Mar 11 01:11:38 2004 +0000 @@ -1542,19 +1542,29 @@ (and (window-system frame) (x-get-resource "backgroundMode" "BackgroundMode"))) (bg-color (frame-parameter frame 'background-color)) + (tty-type (frame-parameter frame 'tty-type)) (bg-mode (cond (frame-background-mode) (bg-resource (intern (downcase bg-resource))) - ((and (null (window-system frame)) (null bg-color)) - ;; No way to determine this automatically (?). - 'dark) - ;; Unspecified frame background color can only happen - ;; on tty's. - ((member bg-color '(unspecified "unspecified-bg")) - 'dark) + ((and (null (window-system frame)) + ;; Unspecified frame background color can only + ;; happen on tty's. + (member bg-color '(nil unspecified "unspecified-bg"))) + ;; There is no way to determine the background mode + ;; automatically, so we make a guess based on the + ;; terminal type. + (if (and tty-type + (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)" + tty-type)) + 'light + 'dark)) ((equal bg-color "unspecified-fg") ; inverted colors - 'light) + (if (and tty-type + (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)" + tty-type)) + 'dark + 'light)) ((>= (apply '+ (x-color-values bg-color frame)) ;; Just looking at the screen, colors whose ;; values add up to .6 of the white total @@ -1746,15 +1756,30 @@ `default-frame-alist'. If either PARAMETERS or `default-frame-alist' contains a `reverse' parameter, handle that. Value is the new frame created." - (let ((frame (make-terminal-frame parameters)) + (let ((old-frame (selected-frame)) + (frame (make-terminal-frame parameters)) success) (unwind-protect (progn + (select-frame frame) (tty-handle-reverse-video frame (frame-parameters frame)) (frame-set-background-mode frame) (face-set-after-frame-default frame) + ;; Load library for our terminal type. + ;; User init file can set term-file-prefix to nil to prevent this. + (unless (null term-file-prefix) + (let ((term (cdr (assq 'tty-type parameters))) + hyphend) + (while (and term + (not (load (concat term-file-prefix term) t t))) + ;; Strip off last hyphen and what follows, then try again + (setq term + (if (setq hyphend (string-match "[-_][^-_]+$" term)) + (substring term 0 hyphend) + nil))))) (setq success t)) (unless success + (select-frame old-frame) (delete-frame frame))) frame))