/* xfaces.c -- "Face" primitives.
-Copyright (C) 1993-1994, 1998-2013 Free Software Foundation, Inc.
+Copyright (C) 1993-1994, 1998-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#define IGNORE_DEFFACE_P(ATTR) EQ ((ATTR), QCignore_defface)
-/* Value is the number of elements of VECTOR. */
-
-#define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR))
-
/* Size of hash table of realized faces in face caches (should be a
prime number). */
static Lisp_Object Qborder, Qmouse, Qmenu;
Lisp_Object Qmode_line_inactive;
static Lisp_Object Qvertical_border;
+static Lisp_Object Qwindow_divider;
+static Lisp_Object Qwindow_divider_first_pixel;
+static Lisp_Object Qwindow_divider_last_pixel;
/* The symbol `face-alias'. A symbols having that property is an
alias for another face. Value of the property is the name of
fputc ('\n', stderr);
- for (i = n = 0; i < sizeof color_count / sizeof color_count[0]; ++i)
+ for (i = n = 0; i < ARRAYELTS (color_count); ++i)
if (color_count[i])
{
fprintf (stderr, "%3d: %5d", i, color_count[i]);
}
-/* Free face cache of frame F. Called from delete_frame. */
+/* Free face cache of frame F. Called from frame-dependent
+ resource freeing function, e.g. (x|tty)_free_frame_resources. */
void
free_frame_faces (struct frame *f)
{
clear_face_cache (!NILP (thoroughly));
++face_change_count;
- ++windows_or_buffers_changed;
+ windows_or_buffers_changed = 53;
return Qnil;
}
X Colors
***********************************************************************/
-#define NEAR_SAME_COLOR_THRESHOLD 30000
-
/* Parse RGB_LIST, and fill in the RGB fields of COLOR.
RGB_LIST should contain (at least) 3 lisp integers.
Return 0 if there's a problem with RGB_LIST, otherwise return 1. */
record that fact in flags of the face so that we don't try to free
these colors. */
-#ifndef MSDOS
-static
-#endif
unsigned long
load_color (struct frame *f, struct face *face, Lisp_Object name,
enum lface_attribute_index target_index)
#ifdef HAVE_WINDOW_SYSTEM
+#define NEAR_SAME_COLOR_THRESHOLD 30000
+
/* Load colors for face FACE which is used on frame F. Colors are
specified by slots LFACE_BACKGROUND_INDEX and LFACE_FOREGROUND_INDEX
of ATTRS. If the background color specified is not supported on F,
int i;
for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
- if (i != LFACE_FONT_INDEX && i != LFACE_INHERIT_INDEX)
+ if (i != LFACE_FONT_INDEX && i != LFACE_INHERIT_INDEX
+ && i != LFACE_DISTANT_FOREGROUND_INDEX)
if ((UNSPECIFIEDP (attrs[i]) || IGNORE_DEFFACE_P (attrs[i])))
break;
if (NILP (Fget (face, Qface_no_inherit)))
{
++face_change_count;
- ++windows_or_buffers_changed;
+ windows_or_buffers_changed = 54;
}
eassert (LFACEP (lface));
if (NILP (Fget (to, Qface_no_inherit)))
{
++face_change_count;
- ++windows_or_buffers_changed;
+ windows_or_buffers_changed = 55;
}
return to;
&& NILP (Fequal (old_value, value)))
{
++face_change_count;
- ++windows_or_buffers_changed;
+ windows_or_buffers_changed = 56;
}
if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)
{
#ifdef HAVE_WINDOW_SYSTEM
/* Changed font-related attributes of the `default' face are
- reflected in changed `font' frame parameters. */
+ reflected in changed `font' frame parameters. */
if (FRAMEP (frame)
&& (prop_index || EQ (attr, QCfont))
&& lface_fully_specified_p (XVECTOR (lface)->contents))
&& NILP (Fget (face, Qface_no_inherit)))
{
++face_change_count;
- ++windows_or_buffers_changed;
+ windows_or_buffers_changed = 57;
}
}
static bool
face_attr_equal_p (Lisp_Object v1, Lisp_Object v2)
{
- /* Type can differ, e.g. when one attribute is unspecified, i.e. nil,
- and the other is specified. */
- if (XTYPE (v1) != XTYPE (v2))
- return 0;
-
- if (EQ (v1, v2))
- return 1;
-
- switch (XTYPE (v1))
- {
- case Lisp_String:
- if (SBYTES (v1) != SBYTES (v2))
- return 0;
-
- return memcmp (SDATA (v1), SDATA (v2), SBYTES (v1)) == 0;
-
- case_Lisp_Int:
- case Lisp_Symbol:
- return 0;
-
- default:
- return !NILP (Fequal (v1, v2));
- }
+ return !NILP (Fequal (v1, v2));
}
}
}
+#ifdef HAVE_WINDOW_SYSTEM
-/* Prepare face FACE for subsequent display on frame F. This
- allocated GCs if they haven't been allocated yet or have been freed
- by clearing the face cache. */
+/* Prepare face FACE for subsequent display on frame F. This must be called
+ before using X resources of FACE to allocate GCs if they haven't been
+ allocated yet or have been freed by clearing the face cache. */
void
prepare_face_for_display (struct frame *f, struct face *face)
{
-#ifdef HAVE_WINDOW_SYSTEM
eassert (FRAME_WINDOW_P (f));
if (face->gc == 0)
font_prepare_for_face (f, face);
unblock_input ();
}
-#endif /* HAVE_WINDOW_SYSTEM */
}
-\f
+#endif /* HAVE_WINDOW_SYSTEM */
+
/* Returns the `distance' between the colors X and Y. */
static int
if (WINDOWP (f->root_window))
{
clear_current_matrices (f);
- ++windows_or_buffers_changed;
+ windows_or_buffers_changed = 58;
}
unblock_input ();
{
Lisp_Object list;
int i;
- int indices[DIM (font_sort_order)];
+ int indices[ARRAYELTS (font_sort_order)];
CHECK_LIST (order);
memset (indices, 0, sizeof indices);
i = 0;
for (list = order;
- CONSP (list) && i < DIM (indices);
+ CONSP (list) && i < ARRAYELTS (indices);
list = XCDR (list), ++i)
{
Lisp_Object attr = XCAR (list);
indices[i] = xlfd;
}
- if (!NILP (list) || i != DIM (indices))
+ if (!NILP (list) || i != ARRAYELTS (indices))
signal_error ("Invalid font sort order", order);
- for (i = 0; i < DIM (font_sort_order); ++i)
+ for (i = 0; i < ARRAYELTS (font_sort_order); ++i)
if (indices[i] == 0)
signal_error ("Invalid font sort order", order);
realize_basic_faces (struct frame *f)
{
bool success_p = 0;
- ptrdiff_t count = SPECPDL_INDEX ();
+ dynwind_begin ();
/* Block input here so that we won't be surprised by an X expose
event, for instance, without having the faces set up. */
realize_named_face (f, Qmouse, MOUSE_FACE_ID);
realize_named_face (f, Qmenu, MENU_FACE_ID);
realize_named_face (f, Qvertical_border, VERTICAL_BORDER_FACE_ID);
+ realize_named_face (f, Qwindow_divider, WINDOW_DIVIDER_FACE_ID);
+ realize_named_face (f, Qwindow_divider_first_pixel,
+ WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
+ realize_named_face (f, Qwindow_divider_last_pixel,
+ WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
/* Reflect changes in the `menu' face in menu bars. */
if (FRAME_FACE_CACHE (f)->menu_face_changed_p)
success_p = 1;
}
- unbind_to (count, Qnil);
+ dynwind_end ();
unblock_input ();
return success_p;
}
emacs_abort ();
}
- if (UNSPECIFIEDP (LFACE_DISTANT_FOREGROUND (lface)))
- ASET (lface, LFACE_DISTANT_FOREGROUND_INDEX, build_string (unspecified_fg));
-
if (UNSPECIFIEDP (LFACE_BACKGROUND (lface)))
{
/* This function is called so early that colors are not yet
face = xmalloc (sizeof *face);
*face = *base_face;
face->gc = 0;
- face->extra = NULL;
face->overstrike
= (! NILP (font_object)
&& FONT_WEIGHT_NAME_NUMERIC (face->lface[LFACE_WEIGHT_INDEX]) > 100
int i;
fprintf (stderr, "font selection order: ");
- for (i = 0; i < DIM (font_sort_order); ++i)
+ for (i = 0; i < ARRAYELTS (font_sort_order); ++i)
fprintf (stderr, "%d ", font_sort_order[i]);
fprintf (stderr, "\n");
void
syms_of_xfaces (void)
{
+#include "xfaces.x"
+
DEFSYM (Qface, "face");
DEFSYM (Qface_no_inherit, "face-no-inherit");
DEFSYM (Qbitmap_spec_p, "bitmap-spec-p");
DEFSYM (Qmouse, "mouse");
DEFSYM (Qmode_line_inactive, "mode-line-inactive");
DEFSYM (Qvertical_border, "vertical-border");
+ DEFSYM (Qwindow_divider, "window-divider");
+ DEFSYM (Qwindow_divider_first_pixel, "window-divider-first-pixel");
+ DEFSYM (Qwindow_divider_last_pixel, "window-divider-last-pixel");
DEFSYM (Qtty_color_desc, "tty-color-desc");
DEFSYM (Qtty_color_standard_values, "tty-color-standard-values");
DEFSYM (Qtty_color_by_index, "tty-color-by-index");
Vface_alternative_font_registry_alist = Qnil;
staticpro (&Vface_alternative_font_registry_alist);
- defsubr (&Sinternal_make_lisp_face);
- defsubr (&Sinternal_lisp_face_p);
- defsubr (&Sinternal_set_lisp_face_attribute);
-#ifdef HAVE_WINDOW_SYSTEM
- defsubr (&Sinternal_set_lisp_face_attribute_from_resource);
-#endif
- defsubr (&Scolor_gray_p);
- defsubr (&Scolor_supported_p);
-#ifndef HAVE_X_WINDOWS
- defsubr (&Sx_load_color_file);
-#endif
- defsubr (&Sface_attribute_relative_p);
- defsubr (&Smerge_face_attribute);
- defsubr (&Sinternal_get_lisp_face_attribute);
- defsubr (&Sinternal_lisp_face_attribute_values);
- defsubr (&Sinternal_lisp_face_equal_p);
- defsubr (&Sinternal_lisp_face_empty_p);
- defsubr (&Sinternal_copy_lisp_face);
- defsubr (&Sinternal_merge_in_global_face);
- defsubr (&Sface_font);
- defsubr (&Sframe_face_alist);
- defsubr (&Sdisplay_supports_face_attributes_p);
- defsubr (&Scolor_distance);
- defsubr (&Sinternal_set_font_selection_order);
- defsubr (&Sinternal_set_alternative_font_family_alist);
- defsubr (&Sinternal_set_alternative_font_registry_alist);
- defsubr (&Sface_attributes_as_vector);
-#ifdef GLYPH_DEBUG
- defsubr (&Sdump_face);
- defsubr (&Sshow_face_resources);
-#endif /* GLYPH_DEBUG */
- defsubr (&Sclear_face_cache);
- defsubr (&Stty_suppress_bold_inverse_default_colors);
-
-#if defined DEBUG_X_COLORS && defined HAVE_X_WINDOWS
- defsubr (&Sdump_colors);
-#endif
-
DEFVAR_LISP ("face-new-frame-defaults", Vface_new_frame_defaults,
doc: /* List of global face definitions (for internal use only.) */);
Vface_new_frame_defaults = Qnil;
\(or smaller) font we should use. For instance, if a face requests
a font of 10 point, we actually use a font of 10 * RESCALE-RATIO point. */);
Vface_font_rescale_alist = Qnil;
-
-#ifdef HAVE_WINDOW_SYSTEM
- defsubr (&Sbitmap_spec_p);
- defsubr (&Sx_list_fonts);
- defsubr (&Sinternal_face_x_get_resource);
- defsubr (&Sx_family_fonts);
-#endif
}