diff src/term.c @ 93883:722fdbc7a012

* xdisp.c (redisplay_internal): Reset tty's color_mode when switching to another frame. * frame.c (do_switch_frame): Refine the top_frame/async_visible code. Don't call set_tty_color_mode. (store_frame_param): Reset previous_frame rather than call set_tty_color_mode. * term.c (set_tty_color_mode): Rewrite. * dispextern.h (set_tty_color_mode): New type. * termchar.h (struct tty_display_info): Add `previous_color_mode'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 09 Apr 2008 03:25:14 +0000
parents 4bf10a5a835d
children ddcecf318c8a
line wrap: on
line diff
--- a/src/term.c	Tue Apr 08 22:13:13 2008 +0000
+++ b/src/term.c	Wed Apr 09 03:25:14 2008 +0000
@@ -2161,56 +2161,38 @@
 }
 
 void
-set_tty_color_mode (f, val)
+set_tty_color_mode (tty, f)
+     struct tty_display_info *tty;
      struct frame *f;
-     Lisp_Object val;
 {
-  Lisp_Object color_mode_spec, current_mode_spec;
-  Lisp_Object color_mode, current_mode;
-  int mode, old_mode;
+  Lisp_Object tem, val, color_mode_spec;
+  Lisp_Object color_mode;
+  int mode;
   extern Lisp_Object Qtty_color_mode;
-  Lisp_Object tty_color_mode_alist;
-
-  tty_color_mode_alist = Fintern_soft (build_string ("tty-color-mode-alist"),
-				       Qnil);
+  Lisp_Object tty_color_mode_alist
+    = Fintern_soft (build_string ("tty-color-mode-alist"), Qnil);
+
+  tem = assq_no_quit (Qtty_color_mode, XFRAME (val)->param_alist);
+  val = CONSP (tem) ? XCDR (tem) : Qnil;
 
   if (INTEGERP (val))
     color_mode = val;
   else
     {
-      if (NILP (tty_color_mode_alist))
-	color_mode_spec = Qnil;
-      else
-	color_mode_spec = Fassq (val, XSYMBOL (tty_color_mode_alist)->value);
-
-      if (CONSP (color_mode_spec))
-	color_mode = XCDR (color_mode_spec);
-      else
-	color_mode = Qnil;
+      tem = (NILP (tty_color_mode_alist) ? Qnil
+	     : Fassq (val, XSYMBOL (tty_color_mode_alist)->value));
+      color_mode = CONSP (tem) ? XCDR (tem) : Qnil;
     }
 
-  current_mode_spec = assq_no_quit (Qtty_color_mode, f->param_alist);
-
-  if (CONSP (current_mode_spec))
-    current_mode = XCDR (current_mode_spec);
-  else
-    current_mode = Qnil;
-  if (INTEGERP (color_mode))
-    mode = XINT (color_mode);
-  else
-    mode = 0;	/* meaning default */
-  if (INTEGERP (current_mode))
-    old_mode = XINT (current_mode);
-  else
-    old_mode = 0;
-
-  if (mode != old_mode)
+  mode = INTEGERP (color_mode) ? XINT (color_mode) : 0;
+
+  if (mode != tty->previous_color_mode)
     {
-      tty_setup_colors (FRAME_TTY (f), mode);
-      /*  This recomputes all the faces given the new color
-	  definitions.  */
-      call0 (intern ("tty-set-up-initial-frame-faces"));
-      redraw_frame (f);
+      Lisp_Object funsym = intern ("tty-set-up-initial-frame-faces");
+      tty->previous_color_mode = mode;
+      tty_setup_colors (tty , mode);
+      /*  This recomputes all the faces given the new color definitions.  */
+      safe_call (1, &funsym);
     }
 }