]> code.delx.au - gnu-emacs/blobdiff - src/xfaces.c
*** empty log message ***
[gnu-emacs] / src / xfaces.c
index a0172ccda4bf1406cfa04b8c206d5ac407d60a56..173c0b45c585f2d9f762241e7d1a8a08b70db37e 100644 (file)
@@ -410,6 +410,13 @@ static int clear_font_table_count;
 
 int face_change_count;
 
+/* Non-zero means don't display bold text if a face's foreground
+   and background colors are the inverse of the default colors of the
+   display.   This is a kluge to suppress `bold black' foreground text
+   which is hard to read on an LCD monitor.  */
+
+int tty_suppress_bold_inverse_default_colors_p;
+
 /* The total number of colors currently allocated.  */
 
 #if GLYPH_DEBUG
@@ -437,7 +444,6 @@ static int x_face_list_fonts P_ ((struct frame *, char *,
 static int font_scalable_p P_ ((struct font_name *));
 static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int));
 static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *));
-static char *xstrdup P_ ((char *));
 static unsigned char *xstrlwr P_ ((unsigned char *));
 static void signal_error P_ ((char *, Lisp_Object));
 static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int));
@@ -500,7 +506,8 @@ static int xlfd_fixed_p P_ ((struct font_name *));
 static int xlfd_numeric_value P_ ((struct table_entry *, int, struct font_name *,
                                   int, int));
 static Lisp_Object xlfd_symbolic_value P_ ((struct table_entry *, int,
-                                           struct font_name *, int, int));
+                                           struct font_name *, int,
+                                           Lisp_Object));
 static struct table_entry *xlfd_lookup_field_contents P_ ((struct table_entry *, int,
                                                           struct font_name *, int));
 
@@ -701,19 +708,6 @@ x_free_gc (f, gc)
 
 #endif  /* WINDOWSNT */
 
-/* Like strdup, but uses xmalloc.  */
-
-static char *
-xstrdup (s)
-     char *s;
-{
-  int len = strlen (s) + 1;
-  char *p = (char *) xmalloc (len);
-  bcopy (s, p, len);
-  return p;
-}
-
-
 /* Like stricmp.  Used to compare parts of font names which are in
    ISO8859-1.  */
 
@@ -1022,7 +1016,7 @@ the pixmap.  Bits are stored row by row, each row occupies\n\
        {
          int bytes_per_row = ((XFASTINT (width) + BITS_PER_CHAR - 1)
                               / BITS_PER_CHAR);
-         if (STRING_BYTES (XSTRING (data)) >= bytes_per_row * height)
+         if (STRING_BYTES (XSTRING (data)) >= bytes_per_row * XINT (height))
            pixmap_p = 1;
        }
     }
@@ -1838,7 +1832,7 @@ xlfd_symbolic_value (table, dim, font, field_index, dflt)
      int dim;
      struct font_name *font;
      int field_index;
-     int dflt;
+     Lisp_Object dflt;
 {
   struct table_entry *p;
   p = xlfd_lookup_field_contents (table, dim, font, field_index);
@@ -4469,9 +4463,9 @@ lface_hash (v)
   return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX])
          ^ hash_string_case_insensitive (v[LFACE_FOREGROUND_INDEX])
          ^ hash_string_case_insensitive (v[LFACE_BACKGROUND_INDEX])
-         ^ (unsigned) v[LFACE_WEIGHT_INDEX]
-         ^ (unsigned) v[LFACE_SLANT_INDEX]
-         ^ (unsigned) v[LFACE_SWIDTH_INDEX]
+         ^ XFASTINT (v[LFACE_WEIGHT_INDEX])
+         ^ XFASTINT (v[LFACE_SLANT_INDEX])
+         ^ XFASTINT (v[LFACE_SWIDTH_INDEX])
          ^ XFASTINT (v[LFACE_HEIGHT_INDEX]));
 }
 
@@ -4864,13 +4858,7 @@ uncache_face (c, face)
    of frame F.  The face will be used to display character C.  Value
    is the ID of the face found.  If no suitable face is found, realize
    a new one.  In that case, if C is a multibyte character, BASE_FACE
-   is a face for ASCII characters that has the same attributes.
-
-   When this function is called from face_for_char (in this case, C is
-   a multibyte character), a fontset of a face returned by
-   realize_face is not yet set, i.e. FACE_SUITABLE_FOR_CHAR_P (FACE,
-   C) is not sutisfied.  The fontset is set for this face by
-   face_for_char later.  */
+   is a face for ASCII characters that has the same attributes.  */
 
 INLINE int
 lookup_face (f, attr, c, base_face)
@@ -4904,6 +4892,12 @@ lookup_face (f, attr, c, base_face)
 
 #if GLYPH_DEBUG
   xassert (face == FACE_FROM_ID (f, face->id));
+
+/* When this function is called from face_for_char (in this case, C is
+   a multibyte character), a fontset of a face returned by
+   realize_face is not yet set, i.e. FACE_SUITABLE_FOR_CHAR_P (FACE,
+   C) is not sutisfied.  The fontset is set for this face by
+   face_for_char later.  */
 #if 0
   if (FRAME_WINDOW_P (f))
     xassert (FACE_SUITABLE_FOR_CHAR_P (face, c));
@@ -5599,6 +5593,10 @@ realize_basic_faces (f)
      struct frame *f;
 {
   int success_p = 0;
+
+  /* Block input there so that we won't be surprised by an X expose
+     event, for instance without having the faces set up.  */
+  BLOCK_INPUT;
   
   if (realize_default_face (f))
     {
@@ -5614,6 +5612,7 @@ realize_basic_faces (f)
       success_p = 1;
     }
 
+  UNBLOCK_INPUT;
   return success_p;
 }
 
@@ -5797,7 +5796,7 @@ realize_face (cache, attrs, c, base_face, former_face_id)
   /* Insert the new face.  */
   cache_face (cache, face, lface_hash (attrs));
 #ifdef HAVE_WINDOW_SYSTEM
-  if (FRAME_X_P (cache->f) && face->font == NULL)
+  if (FRAME_WINDOW_P (cache->f) && face->font == NULL)
     load_face_font (cache->f, face, c);
 #endif  /* HAVE_WINDOW_SYSTEM */
   return face;
@@ -6027,8 +6026,8 @@ realize_tty_face (cache, attrs, c)
   struct face *face;
   int weight, slant;
   Lisp_Object color;
-  Lisp_Object tty_defined_color_alist =
-    Fsymbol_value (intern ("tty-defined-color-alist"));
+  Lisp_Object tty_defined_color_alist
+    = find_symbol_value (intern ("tty-defined-color-alist"));
   Lisp_Object tty_color_alist = intern ("tty-color-alist");
   Lisp_Object frame;
   int face_colors_defaulted = 0;
@@ -6063,7 +6062,7 @@ realize_tty_face (cache, attrs, c)
   color = attrs[LFACE_FOREGROUND_INDEX];
   if (STRINGP (color)
       && XSTRING (color)->size
-      && !NILP (tty_defined_color_alist)
+      && CONSP (tty_defined_color_alist)
       && (color = Fassoc (color, call1 (tty_color_alist, frame)),
          CONSP (color)))
     /* Associations in tty-defined-color-alist are of the form
@@ -6109,7 +6108,7 @@ realize_tty_face (cache, attrs, c)
   color = attrs[LFACE_BACKGROUND_INDEX];
   if (STRINGP (color)
       && XSTRING (color)->size
-      && !NILP (tty_defined_color_alist)
+      && CONSP (tty_defined_color_alist)
       && (color = Fassoc (color, call1 (tty_color_alist, frame)),
          CONSP (color)))
     /* Associations in tty-defined-color-alist are of the form
@@ -6162,10 +6161,33 @@ realize_tty_face (cache, attrs, c)
       face->background = tem;
     }
 
+  if (tty_suppress_bold_inverse_default_colors_p
+      && face->tty_bold_p
+      && face->background == FACE_TTY_DEFAULT_FG_COLOR
+      && face->foreground == FACE_TTY_DEFAULT_BG_COLOR)
+    face->tty_bold_p = 0;
+
   return face;
 }
 
 
+DEFUN ("tty-suppress-bold-inverse-default-colors",
+       Ftty_suppress_bold_inverse_default_colors,
+       Stty_suppress_bold_inverse_default_colors, 1, 1, 0,
+  "Suppress/allow boldness of faces with inverse default colors.\n\
+SUPPRESS non-nil means suppress it.\n\
+This affects bold faces on TTYs whose foreground is the default background\n\
+color of the display and whose background is the default foreground color.\n\
+For such faces, no bold text will be displayed.")
+  (suppress)
+     Lisp_Object suppress;
+{
+  tty_suppress_bold_inverse_default_colors_p = !NILP (suppress);
+  ++face_change_count;
+  return suppress;
+}
+
+
 \f
 /***********************************************************************
                           Computing Faces
@@ -6678,6 +6700,7 @@ syms_of_xfaces ()
   defsubr (&Sshow_face_resources);
 #endif /* GLYPH_DEBUG */
   defsubr (&Sclear_face_cache);
+  defsubr (&Stty_suppress_bold_inverse_default_colors);
 
   DEFVAR_LISP ("font-list-limit", &Vfont_list_limit,
     "*Limit for font matching.\n\