]> code.delx.au - gnu-emacs/blobdiff - src/w32faces.c
(Vnonascii_translation_table): Name changed from
[gnu-emacs] / src / w32faces.c
index dd0cbbaa8a7c441bb775c27aba6fa5f075a1b134..cc61c5017ec07f3eaf4e31ff3b2ed4eab869cc13 100644 (file)
@@ -1,4 +1,4 @@
-/* "Face" primitives.
+/* "Face" primitives on the Microsoft W32 API.
    Copyright (C) 1993, 1994, 1995 Free Software Foundation.
 
 This file is part of GNU Emacs.
@@ -15,9 +15,10 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
-/* Ported xfaces.c for win32 - Kevin Gallo */
+/* Ported xfaces.c for w32 - Kevin Gallo */
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -69,7 +70,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
    lisp manipulates to control what gets displayed.  Elements 0 and 1
    of FRAME->display.x->param_faces are special - they describe the
    default and mode line faces.  None of the faces in param_faces have
-   GC's.  (See src/dispextern.h for the definiton of struct face.
+   GC's.  (See src/dispextern.h for the definition of struct face.
    lisp/faces.el maintains the isomorphism between face_alist and
    param_faces.)
 
@@ -138,6 +139,9 @@ static int new_computed_face ( /* FRAME_PTR, struct face * */ );
 static int intern_computed_face ( /* FRAME_PTR, struct face * */ );
 static void ensure_face_ready ( /* FRAME_PTR, int id */ );
 void recompute_basic_faces ( /* FRAME_PTR f */ );
+static void merge_face_list ( /* FRAME_PTR, struct face *, Lisp_Object */ );
+
+extern Lisp_Object Qforeground_color, Qbackground_color;
 \f
 /* Allocating, copying, and comparing struct faces.  */
 
@@ -226,7 +230,7 @@ load_font (f, name)
 
   CHECK_STRING (name, 0);
   BLOCK_INPUT;
-  font = win32_load_font (FRAME_WIN32_DISPLAY_INFO (f), (char *) XSTRING (name)->data);
+  font = w32_load_font (FRAME_W32_DISPLAY_INFO (f), (char *) XSTRING (name)->data);
   UNBLOCK_INPUT;
 
   if (! font)
@@ -244,7 +248,7 @@ unload_font (f, font)
     return;
 
   BLOCK_INPUT;
-  win32_unload_font (FRAME_WIN32_DISPLAY_INFO (f), font);
+  w32_unload_font (FRAME_W32_DISPLAY_INFO (f), font);
   UNBLOCK_INPUT;
 }
 
@@ -372,14 +376,13 @@ init_frame_faces (f)
   new_computed_face (f, FRAME_PARAM_FACES (f)[1]);
   recompute_basic_faces (f);
 
-#ifdef MULTI_FRAME
   /* Find another frame.  */
   {
     Lisp_Object tail, frame, result;
     
     result = Qnil;
     FOR_EACH_FRAME (tail, frame)
-      if (FRAME_WIN32_P (XFRAME (frame))
+      if (FRAME_W32_P (XFRAME (frame))
          && XFRAME (frame) != f)
        {
          result = frame;
@@ -401,7 +404,6 @@ init_frame_faces (f)
            ensure_face_ready (f, i);
       }
   }
-#endif /* MULTI_FRAME */
 }
 
 
@@ -547,21 +549,21 @@ frame_update_line_height (f)
      FRAME_PTR f;
 {
   int i;
-  int biggest = FONT_HEIGHT (f->output_data.win32->font);
+  int biggest = FONT_HEIGHT (f->output_data.w32->font);
 
-  for (i = 0; i < f->output_data.win32->n_param_faces; i++)
-    if (f->output_data.win32->param_faces[i] != 0
-       && f->output_data.win32->param_faces[i]->font != (XFontStruct *) FACE_DEFAULT)
+  for (i = 0; i < f->output_data.w32->n_param_faces; i++)
+    if (f->output_data.w32->param_faces[i] != 0
+       && f->output_data.w32->param_faces[i]->font != (XFontStruct *) FACE_DEFAULT)
       {
-       int height = FONT_HEIGHT (f->output_data.win32->param_faces[i]->font);
+       int height = FONT_HEIGHT (f->output_data.w32->param_faces[i]->font);
        if (height > biggest)
          biggest = height;
       }
 
-  if (biggest == f->output_data.win32->line_height)
+  if (biggest == f->output_data.w32->line_height)
     return 0;
 
-  f->output_data.win32->line_height = biggest;
+  f->output_data.w32->line_height = biggest;
   return 1;
 }
 \f
@@ -664,7 +666,6 @@ compute_glyph_face_1 (f, face_name, current_face)
    the time this function can take.
 
    If MOUSE is nonzero, use the character's mouse-face, not its face.  */
-
 int
 compute_char_face (f, w, pos, region_beg, region_end, endptr, limit, mouse)
      struct frame *f;
@@ -747,82 +748,23 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr, limit, mouse)
 
   compute_base_face (f, &face);
 
-  if (CONSP (prop))
-    {
-      /* We have a list of faces, merge them in reverse order */
-      Lisp_Object length = Flength (prop);
-      int len = XINT (length);
-      Lisp_Object *faces;
-
-      /* Put them into an array */
-      faces = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
-      for (j = 0; j < len; j++)
-       {
-         faces[j] = Fcar (prop);
-         prop = Fcdr (prop);
-       }
-      /* So that we can merge them in the reverse order */
-      for (j = len - 1; j >= 0; j--)
-       {
-         facecode = face_name_id_number (f, faces[j]);
-         if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
-             && FRAME_PARAM_FACES (f) [facecode] != 0)
-           merge_faces (FRAME_PARAM_FACES (f) [facecode], &face);
-       }
-    }
-  else if (!NILP (prop))
-    {
-      facecode = face_name_id_number (f, prop);
-      if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
-         && FRAME_PARAM_FACES (f) [facecode] != 0)
-       merge_faces (FRAME_PARAM_FACES (f) [facecode], &face);
-    }
+  merge_face_list (f, &face, prop);
 
   noverlays = sort_overlays (overlay_vec, noverlays, w);
 
   /* Now merge the overlay data in that order.  */
   for (i = 0; i < noverlays; i++)
     {
-      prop = Foverlay_get (overlay_vec[i], propname);
-      if (CONSP (prop))
-       {
-         /* We have a list of faces, merge them in reverse order */
-         Lisp_Object length = Flength (prop);
-         int len = XINT (length);
-         Lisp_Object *faces;
-         int i;
-
-         /* Put them into an array */
-         faces = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
-         for (j = 0; j < len; j++)
-           {
-             faces[j] = Fcar (prop);
-             prop = Fcdr (prop);
-           }
-         /* So that we can merge them in the reverse order */
-         for (j = len - 1; j >= 0; j--)
-           {
-             facecode = face_name_id_number (f, faces[j]);
-             if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
-                 && FRAME_PARAM_FACES (f) [facecode] != 0)
-               merge_faces (FRAME_PARAM_FACES (f) [facecode], &face);
-           }
-       }
-      else if (!NILP (prop))
-       {
-         Lisp_Object oend;
-         int oendpos;
+      Lisp_Object oend;
+      int oendpos;
 
-         facecode = face_name_id_number (f, prop);
-         if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
-             && FRAME_PARAM_FACES (f) [facecode] != 0)
-           merge_faces (FRAME_PARAM_FACES (f)[facecode], &face);
+      prop = Foverlay_get (overlay_vec[i], propname);
+      merge_face_list (f, &face, prop);
 
-         oend = OVERLAY_END (overlay_vec[i]);
-         oendpos = OVERLAY_POSITION (oend);
-         if (oendpos < endpos)
-           endpos = oendpos;
-       }
+      oend = OVERLAY_END (overlay_vec[i]);
+      oendpos = OVERLAY_POSITION (oend);
+      if (oendpos < endpos)
+       endpos = oendpos;
     }
 
   if (pos >= region_beg && pos < region_end)
@@ -837,6 +779,61 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr, limit, mouse)
 
   return intern_computed_face (f, &face);
 }
+
+static void
+merge_face_list (f, face, prop)
+     FRAME_PTR f;
+     struct face *face;
+     Lisp_Object prop;
+{
+  Lisp_Object length;
+  int len;
+  Lisp_Object *faces;
+  int j;
+
+  if (CONSP (prop)
+      && ! STRINGP (XCONS (prop)->cdr))
+    {
+      /* We have a list of faces, merge them in reverse order.  */
+
+      length = Fsafe_length (prop);
+      len = XFASTINT (length);
+
+      /* Put them into an array.  */
+      faces = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
+      for (j = 0; j < len; j++)
+       {
+         faces[j] = Fcar (prop);
+         prop = Fcdr (prop);
+       }
+      /* So that we can merge them in the reverse order.  */
+    }
+  else
+    {
+      faces = (Lisp_Object *) alloca (sizeof (Lisp_Object));
+      faces[0] = prop;
+      len = 1;
+    }
+
+  for (j = len - 1; j >= 0; j--)
+    {
+      if (CONSP (faces[j]))
+       {
+         if (EQ (XCONS (faces[j])->car, Qbackground_color))
+           face->background = load_color (f, XCONS (faces[j])->cdr);
+         if (EQ (XCONS (faces[j])->car, Qforeground_color))
+           face->foreground = load_color (f, XCONS (faces[j])->cdr);
+       }
+      else
+       {
+         int facecode = face_name_id_number (f, faces[j]);
+         if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f)
+             && FRAME_PARAM_FACES (f) [facecode] != 0)
+           merge_faces (FRAME_PARAM_FACES (f) [facecode], face);
+       }
+    }
+}
+
 \f
 /* Recompute the GC's for the default and modeline faces.
    We call this after changing frame parameters on which those GC's
@@ -903,7 +900,7 @@ DEFUN ("make-face-internal", Fmake_face_internal, Smake_face_internal, 1, 1, 0,
 
   FOR_EACH_FRAME (rest, frame)
     {
-      if (FRAME_WIN32_P (XFRAME (frame)))
+      if (FRAME_W32_P (XFRAME (frame)))
        ensure_face_ready (XFRAME (frame), id);
     }
   return Qnil;
@@ -930,7 +927,7 @@ DEFUN ("set-face-attribute-internal", Fset_face_attribute_internal,
   if (id < 0 || id >= next_face_id)
     error ("Face id out of range");
 
-  if (! FRAME_WIN32_P (f))
+  if (! FRAME_W32_P (f))
     return Qnil;
 
   ensure_face_ready (f, id);
@@ -939,7 +936,7 @@ DEFUN ("set-face-attribute-internal", Fset_face_attribute_internal,
   if (EQ (attr_name, intern ("font")))
     {
       XFontStruct *font = load_font (f, attr_value);
-      if (face->font != f->output_data.win32->font)
+      if (face->font != f->output_data.w32->font)
        unload_font (f, face->font);
       face->font = font;
       if (frame_update_line_height (f))
@@ -1025,7 +1022,7 @@ face_name_id_number (f, name)
 /* Emacs initialization.  */
 
 void
-syms_of_win32faces ()
+syms_of_w32faces ()
 {
   Qface = intern ("face");
   staticpro (&Qface);