#undef FRAME_X_DISPLAY_INFO
#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO
#define x_display_info w32_display_info
-#define FRAME_X_FONT_TABLE FRAME_W32_FONT_TABLE
#define check_x check_w32
#define GCGraphicsExposures 0
#endif /* WINDOWSNT */
#undef FRAME_X_DISPLAY_INFO
#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO
#define x_display_info ns_display_info
-#define FRAME_X_FONT_TABLE FRAME_NS_FONT_TABLE
#define check_x check_ns
#define GCGraphicsExposures 0
#endif /* HAVE_NS */
Lisp_Object Qnormal;
Lisp_Object Qbold;
+static Lisp_Object Qline, Qwave;
static Lisp_Object Qultra_light, Qextra_light, Qlight;
static Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold;
static Lisp_Object Qoblique, Qreverse_oblique, Qreverse_italic;
/* The total number of colors currently allocated. */
-#if GLYPH_DEBUG
+#ifdef GLYPH_DEBUG
static int ncolors_allocated;
static int npixmaps_allocated;
static int ngcs;
void
register_color (unsigned long pixel)
{
- xassert (pixel < 256);
+ eassert (pixel < 256);
++color_count[pixel];
}
void
unregister_color (unsigned long pixel)
{
- xassert (pixel < 256);
+ eassert (pixel < 256);
if (color_count[pixel] > 0)
--color_count[pixel];
else
x_free_gc (struct frame *f, GC gc)
{
eassert (interrupt_input_blocked);
- IF_DEBUG (xassert (--ngcs >= 0));
+ IF_DEBUG (eassert (--ngcs >= 0));
XFreeGC (FRAME_X_DISPLAY (f), gc);
}
static inline void
x_free_gc (struct frame *f, GC gc)
{
- IF_DEBUG (xassert (--ngcs >= 0));
+ IF_DEBUG (eassert (--ngcs >= 0));
xfree (gc);
}
unsigned long mask,
XGCValues *xgcv)
{
- GC gc = xmalloc (sizeof (*gc));
- if (gc)
- memcpy (gc, xgcv, sizeof (XGCValues));
+ GC gc = xmalloc (sizeof *gc);
+ memcpy (gc, xgcv, sizeof (XGCValues));
return gc;
}
}
#endif /* HAVE_NS */
-/* Like strcasecmp/stricmp. Used to compare parts of font names which
- are in ISO8859-1. */
-
-int
-xstrcasecmp (const char *s1, const char *s2)
-{
- while (*s1 && *s2)
- {
- unsigned char b1 = *s1;
- unsigned char b2 = *s2;
- unsigned char c1 = tolower (b1);
- unsigned char c2 = tolower (b2);
- if (c1 != c2)
- return c1 < c2 ? -1 : 1;
- ++s1, ++s2;
- }
-
- if (*s1 == 0)
- return *s2 == 0 ? 0 : -1;
- return 1;
-}
-
-
/* If FRAME is nil, return a pointer to the selected frame.
Otherwise, check that FRAME is a live frame, and return a pointer
to it. NPARAM is the parameter number of FRAME, for
else if (CONSP (object))
{
/* Otherwise OBJECT must be (WIDTH HEIGHT DATA), WIDTH and
- HEIGHT must be integers > 0, and DATA must be string large
+ HEIGHT must be ints > 0, and DATA must be string large
enough to hold a bitmap of the specified size. */
Lisp_Object width, height, data;
}
if (STRINGP (data)
- && INTEGERP (width) && 0 < XINT (width)
- && INTEGERP (height) && 0 < XINT (height))
+ && RANGED_INTEGERP (1, width, INT_MAX)
+ && RANGED_INTEGERP (1, height, INT_MAX))
{
- EMACS_INT bytes_per_row = ((XINT (width) + BITS_PER_CHAR - 1)
- / BITS_PER_CHAR);
+ int bytes_per_row = ((XINT (width) + BITS_PER_CHAR - 1)
+ / BITS_PER_CHAR);
if (XINT (height) <= SBYTES (data) / bytes_per_row)
pixmap_p = 1;
}
}
else
{
-#if GLYPH_DEBUG
+#ifdef GLYPH_DEBUG
++npixmaps_allocated;
#endif
if (w_ptr)
{
XColor color;
- xassert (STRINGP (name));
- xassert (target_index == LFACE_FOREGROUND_INDEX
+ eassert (STRINGP (name));
+ eassert (target_index == LFACE_FOREGROUND_INDEX
|| target_index == LFACE_BACKGROUND_INDEX
|| target_index == LFACE_UNDERLINE_INDEX
|| target_index == LFACE_OVERLINE_INDEX
abort ();
}
}
-#if GLYPH_DEBUG
+#ifdef GLYPH_DEBUG
else
++ncolors_allocated;
#endif
else
{
if (INTEGERP (val1))
- result = INTEGERP (val2) ? XINT (val1) - XINT (val2) : -1;
+ result = (INTEGERP (val2) && XINT (val1) >= XINT (val2)
+ ? XINT (val1) > XINT (val2)
+ : -1);
else
result = INTEGERP (val2) ? 1 : 0;
}
(Lisp_Object family, Lisp_Object frame)
{
Lisp_Object font_spec, list, *drivers, vec;
- int i, nfonts, ndrivers;
+ ptrdiff_t i, nfonts;
+ EMACS_INT ndrivers;
Lisp_Object result;
+ USE_SAFE_ALLOCA;
if (NILP (frame))
frame = selected_frame;
font_props_for_sorting[i++] = FONT_REGISTRY_INDEX;
ndrivers = XINT (Flength (list));
- drivers = alloca (sizeof (Lisp_Object) * ndrivers);
+ SAFE_ALLOCA_LISP (drivers, ndrivers);
for (i = 0; i < ndrivers; i++, list = XCDR (list))
drivers[i] = XCAR (list);
vec = Fvconcat (ndrivers, drivers);
result = Fcons (v, result);
}
+ SAFE_FREE ();
return result;
}
#define LFACE_INHERIT(LFACE) AREF ((LFACE), LFACE_INHERIT_INDEX)
#define LFACE_FONTSET(LFACE) AREF ((LFACE), LFACE_FONTSET_INDEX)
-#if XASSERTS
/* Non-zero if LFACE is a Lisp face. A Lisp face is a vector of size
LFACE_VECTOR_SIZE which has the symbol `face' in slot 0. */
(VECTORP (LFACE) \
&& ASIZE (LFACE) == LFACE_VECTOR_SIZE \
&& EQ (AREF (LFACE, 0), Qface))
-#endif
-#if GLYPH_DEBUG
+#ifdef GLYPH_DEBUG
/* Check consistency of Lisp face attribute vector ATTRS. */
static void
check_lface_attrs (Lisp_Object *attrs)
{
- xassert (UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_FAMILY_INDEX])
|| STRINGP (attrs[LFACE_FAMILY_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_FOUNDRY_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_FOUNDRY_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_FOUNDRY_INDEX])
|| STRINGP (attrs[LFACE_FOUNDRY_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_SWIDTH_INDEX])
|| SYMBOLP (attrs[LFACE_SWIDTH_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_HEIGHT_INDEX])
|| INTEGERP (attrs[LFACE_HEIGHT_INDEX])
|| FLOATP (attrs[LFACE_HEIGHT_INDEX])
|| FUNCTIONP (attrs[LFACE_HEIGHT_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_WEIGHT_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_WEIGHT_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_WEIGHT_INDEX])
|| SYMBOLP (attrs[LFACE_WEIGHT_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_SLANT_INDEX])
|| SYMBOLP (attrs[LFACE_SLANT_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_UNDERLINE_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_UNDERLINE_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_UNDERLINE_INDEX])
|| SYMBOLP (attrs[LFACE_UNDERLINE_INDEX])
- || STRINGP (attrs[LFACE_UNDERLINE_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX])
+ || STRINGP (attrs[LFACE_UNDERLINE_INDEX])
+ || CONSP (attrs[LFACE_UNDERLINE_INDEX]));
+ eassert (UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_OVERLINE_INDEX])
|| SYMBOLP (attrs[LFACE_OVERLINE_INDEX])
|| STRINGP (attrs[LFACE_OVERLINE_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_STRIKE_THROUGH_INDEX])
|| SYMBOLP (attrs[LFACE_STRIKE_THROUGH_INDEX])
|| STRINGP (attrs[LFACE_STRIKE_THROUGH_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_BOX_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_BOX_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_BOX_INDEX])
|| SYMBOLP (attrs[LFACE_BOX_INDEX])
|| STRINGP (attrs[LFACE_BOX_INDEX])
|| INTEGERP (attrs[LFACE_BOX_INDEX])
|| CONSP (attrs[LFACE_BOX_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_INVERSE_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_INVERSE_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_INVERSE_INDEX])
|| SYMBOLP (attrs[LFACE_INVERSE_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_FOREGROUND_INDEX])
|| STRINGP (attrs[LFACE_FOREGROUND_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_BACKGROUND_INDEX])
|| STRINGP (attrs[LFACE_BACKGROUND_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_INHERIT_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_INHERIT_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_INHERIT_INDEX])
|| NILP (attrs[LFACE_INHERIT_INDEX])
|| SYMBOLP (attrs[LFACE_INHERIT_INDEX])
|| CONSP (attrs[LFACE_INHERIT_INDEX]));
#ifdef HAVE_WINDOW_SYSTEM
- xassert (UNSPECIFIEDP (attrs[LFACE_STIPPLE_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_STIPPLE_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_STIPPLE_INDEX])
|| SYMBOLP (attrs[LFACE_STIPPLE_INDEX])
|| !NILP (Fbitmap_spec_p (attrs[LFACE_STIPPLE_INDEX])));
- xassert (UNSPECIFIEDP (attrs[LFACE_FONT_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_FONT_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_FONT_INDEX])
|| FONTP (attrs[LFACE_FONT_INDEX]));
- xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX])
+ eassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX])
|| STRINGP (attrs[LFACE_FONTSET_INDEX])
|| NILP (attrs[LFACE_FONTSET_INDEX]));
#endif
{
if (!NILP (lface))
{
- xassert (LFACEP (lface));
+ eassert (LFACEP (lface));
check_lface_attrs (XVECTOR (lface)->contents);
}
}
-#else /* GLYPH_DEBUG == 0 */
+#else /* not GLYPH_DEBUG */
#define check_lface_attrs(attrs) (void) 0
#define check_lface(lface) (void) 0
-#endif /* GLYPH_DEBUG == 0 */
+#endif /* GLYPH_DEBUG */
\f
{
int pt = PIXEL_TO_POINT (font->pixel_size * 10, f->resy);
- xassert (pt > 0);
+ eassert (pt > 0);
LFACE_HEIGHT (lface) = make_number (pt);
}
{
if (INTEGERP (to))
/* relative X absolute => absolute */
- result = make_number ((EMACS_INT)(XFLOAT_DATA (from) * XINT (to)));
+ result = make_number (XFLOAT_DATA (from) * XINT (to));
else if (FLOATP (to))
/* relative X relative => relative */
result = make_float (XFLOAT_DATA (from) * XFLOAT_DATA (to));
{
/* Call function with current height as argument.
From is the new height. */
- Lisp_Object args[2];
-
- args[0] = from;
- args[1] = to;
- result = safe_call (2, args);
+ result = safe_call1 (from, to);
/* Ensure that if TO was absolute, so is the result. */
if (INTEGERP (to) && !INTEGERP (result))
{
if (EQ (value, Qt)
|| NILP (value)
- || STRINGP (value))
+ || STRINGP (value)
+ || CONSP (value))
to[LFACE_UNDERLINE_INDEX] = value;
else
err = 1;
property `face' of the Lisp face name. */
if (next_lface_id == lface_id_to_name_size)
lface_id_to_name =
- xpalloc (lface_id_to_name, &lface_id_to_name_size, 1,
- min (INT_MAX, MOST_POSITIVE_FIXNUM),
+ xpalloc (lface_id_to_name, &lface_id_to_name_size, 1, MAX_FACE_ID,
sizeof *lface_id_to_name);
lface_id_to_name[next_lface_id] = face;
++windows_or_buffers_changed;
}
- xassert (LFACEP (lface));
+ eassert (LFACEP (lface));
check_lface (lface);
return lface;
}
}
else if (EQ (attr, QCunderline))
{
- if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value))
- if ((SYMBOLP (value)
- && !EQ (value, Qt)
- && !EQ (value, Qnil))
- /* Underline color. */
- || (STRINGP (value)
- && SCHARS (value) == 0))
- signal_error ("Invalid face underline", value);
+ int valid_p = 0;
+
+ if (UNSPECIFIEDP (value) || IGNORE_DEFFACE_P (value))
+ valid_p = 1;
+ else if (NILP (value) || EQ (value, Qt))
+ valid_p = 1;
+ else if (STRINGP (value) && SCHARS (value) > 0)
+ valid_p = 1;
+ else if (CONSP (value))
+ {
+ Lisp_Object key, val, list;
+
+ list = value;
+ valid_p = 1;
+
+ while (!NILP (CAR_SAFE(list)))
+ {
+ key = CAR_SAFE (list);
+ list = CDR_SAFE (list);
+ val = CAR_SAFE (list);
+ list = CDR_SAFE (list);
+
+ if (NILP (key) || NILP (val))
+ {
+ valid_p = 0;
+ break;
+ }
+
+ else if (EQ (key, QCcolor)
+ && !(EQ (val, Qforeground_color)
+ || (STRINGP (val) && SCHARS (val) > 0)))
+ {
+ valid_p = 0;
+ break;
+ }
+
+ else if (EQ (key, QCstyle)
+ && !(EQ (val, Qline) || EQ (val, Qwave)))
+ {
+ valid_p = 0;
+ break;
+ }
+ }
+ }
+
+ if (!valid_p)
+ signal_error ("Invalid face underline", value);
old_value = LFACE_UNDERLINE (lface);
LFACE_UNDERLINE (lface) = value;
/* Changing the background color might change the background
mode, so that we have to load new defface specs.
- Call frame-update-face-colors to do that. */
+ Call frame-set-background-mode to do that. */
XSETFRAME (frame, f);
call1 (Qframe_set_background_mode, frame);
{
Lisp_Object result = make_number (0);
- xassert (STRINGP (value));
+ eassert (STRINGP (value));
if (xstrcasecmp (SSDATA (value), "on") == 0
|| xstrcasecmp (SSDATA (value), "true") == 0)
{
const unsigned char *s;
unsigned hash = 0;
- xassert (STRINGP (string));
+ eassert (STRINGP (string));
for (s = SDATA (string); *s; ++s)
hash = (hash << 1) ^ tolower (*s);
return hash;
static inline int
lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2)
{
- xassert (lface_fully_specified_p (lface1)
+ eassert (lface_fully_specified_p (lface1)
&& lface_fully_specified_p (lface2));
return (xstrcasecmp (SSDATA (lface1[LFACE_FAMILY_INDEX]),
SSDATA (lface2[LFACE_FAMILY_INDEX])) == 0
static struct face *
make_realized_face (Lisp_Object *attr)
{
- struct face *face = (struct face *) xmalloc (sizeof *face);
- memset (face, 0, sizeof *face);
+ struct face *face = xzalloc (sizeof *face);
face->ascii_face = face;
memcpy (face->lface, attr, sizeof face->lface);
return face;
prepare_face_for_display (struct frame *f, struct face *face)
{
#ifdef HAVE_WINDOW_SYSTEM
- xassert (FRAME_WINDOW_P (f));
+ eassert (FRAME_WINDOW_P (f));
if (face->gc == 0)
{
struct face_cache *c;
int size;
- c = (struct face_cache *) xmalloc (sizeof *c);
- memset (c, 0, sizeof *c);
+ c = xzalloc (sizeof *c);
size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
- c->buckets = (struct face **) xmalloc (size);
- memset (c->buckets, 0, size);
+ c->buckets = xzalloc (size);
c->size = 50;
- c->faces_by_id = (struct face **) xmalloc (c->size * sizeof *c->faces_by_id);
+ c->faces_by_id = xmalloc (c->size * sizeof *c->faces_by_id);
c->f = f;
c->menu_face_changed_p = menu_face_changed_default;
return c;
break;
face->id = i;
-#if GLYPH_DEBUG
+#ifdef GLYPH_DEBUG
/* Check that FACE got a unique id. */
{
int j, n;
if (face1->id == i)
++n;
- xassert (n == 1);
+ eassert (n == 1);
}
#endif /* GLYPH_DEBUG */
int i;
struct face *face;
- xassert (cache != NULL);
+ eassert (cache != NULL);
check_lface_attrs (attr);
/* Look up ATTR in the face cache. */
if (face == NULL)
face = realize_face (cache, attr, -1);
-#if GLYPH_DEBUG
- xassert (face == FACE_FROM_ID (f, face->id));
+#ifdef GLYPH_DEBUG
+ eassert (face == FACE_FROM_ID (f, face->id));
#endif /* GLYPH_DEBUG */
return face->id;
int i;
struct face *face;
- xassert (cache != NULL);
+ eassert (cache != NULL);
base_face = base_face->ascii_face;
hash = lface_hash (base_face->lface);
i = hash % FACE_CACHE_BUCKETS_SIZE;
}
-/* Return the display face-id of the basic face who's canonical face-id
+/* Return the display face-id of the basic face whose canonical face-id
is FACE_ID. The return value will usually simply be FACE_ID, unless that
basic face has bee remapped via Vface_remapping_alist. This function is
conservative: if something goes wrong, it will simply return FACE_ID
tty_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs,
struct face *def_face)
{
- int weight;
+ int weight, slant;
Lisp_Object val, fg, bg;
XColor fg_tty_color, fg_std_color;
XColor bg_tty_color, bg_std_color;
unsigned test_caps = 0;
Lisp_Object *def_attrs = def_face->lface;
-
/* First check some easy-to-check stuff; ttys support none of the
following attributes, so we can just return false if any are requested
(even if `nominal' values are specified, we should still return false,
|| !UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX])
|| !UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX])
|| !UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX])
- || !UNSPECIFIEDP (attrs[LFACE_BOX_INDEX])
- || !UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX]))
+ || !UNSPECIFIEDP (attrs[LFACE_BOX_INDEX]))
return 0;
-
/* Test for terminal `capabilities' (non-color character attributes). */
/* font weight (bold/dim) */
return 0; /* same as default */
}
+ /* font slant */
+ val = attrs[LFACE_SLANT_INDEX];
+ if (!UNSPECIFIEDP (val)
+ && (slant = FONT_SLANT_NAME_NUMERIC (val), slant >= 0))
+ {
+ int def_slant = FONT_SLANT_NAME_NUMERIC (def_attrs[LFACE_SLANT_INDEX]);
+ if (slant == 100 || slant == def_slant)
+ return 0; /* same as default */
+ else
+ test_caps |= TTY_CAP_ITALIC;
+ }
+
/* underlining */
val = attrs[LFACE_UNDERLINE_INDEX];
if (!UNSPECIFIEDP (val))
realize_basic_faces (struct frame *f)
{
int success_p = 0;
- int count = SPECPDL_INDEX ();
+ ptrdiff_t count = SPECPDL_INDEX ();
/* Block input here so that we won't be surprised by an X expose
event, for instance, without having the faces set up. */
/* If the `default' face is not yet known, create it. */
lface = lface_from_face_name (f, Qdefault, 0);
if (NILP (lface))
- {
+ {
Lisp_Object frame;
XSETFRAME (frame, f);
lface = Finternal_make_lisp_face (Qdefault, frame);
- }
+ }
#ifdef HAVE_WINDOW_SYSTEM
if (FRAME_WINDOW_P (f))
LFACE_STIPPLE (lface) = Qnil;
/* Realize the face; it must be fully-specified now. */
- xassert (lface_fully_specified_p (XVECTOR (lface)->contents));
+ eassert (lface_fully_specified_p (XVECTOR (lface)->contents));
check_lface (lface);
memcpy (attrs, XVECTOR (lface)->contents, sizeof attrs);
face = realize_face (c, attrs, DEFAULT_FACE_ID);
/* The default face must exist and be fully specified. */
get_lface_attributes_no_remap (f, Qdefault, attrs, 1);
check_lface_attrs (attrs);
- xassert (lface_fully_specified_p (attrs));
+ eassert (lface_fully_specified_p (attrs));
/* If SYMBOL isn't know as a face, create it. */
if (NILP (lface))
struct face *face;
/* LFACE must be fully specified. */
- xassert (cache != NULL);
+ eassert (cache != NULL);
check_lface_attrs (attrs);
if (former_face_id >= 0 && cache->used > former_face_id)
struct face_cache *cache = FRAME_FACE_CACHE (f);
struct face *face;
- face = (struct face *) xmalloc (sizeof *face);
+ face = xmalloc (sizeof *face);
*face = *base_face;
face->gc = 0;
face->extra = NULL;
#ifdef HAVE_WINDOW_SYSTEM
struct face *default_face;
struct frame *f;
- Lisp_Object stipple, overline, strike_through, box;
+ Lisp_Object stipple, underline, overline, strike_through, box;
- xassert (FRAME_WINDOW_P (cache->f));
+ eassert (FRAME_WINDOW_P (cache->f));
/* Allocate a new realized face. */
face = make_realized_face (attrs);
{
/* Simple box of specified line width in foreground color of the
face. */
- xassert (XINT (box) != 0);
+ eassert (XINT (box) != 0);
face->box = FACE_SIMPLE_BOX;
face->box_line_width = XINT (box);
face->box_color = face->foreground;
/* Text underline, overline, strike-through. */
- if (EQ (attrs[LFACE_UNDERLINE_INDEX], Qt))
+ underline = attrs[LFACE_UNDERLINE_INDEX];
+ if (EQ (underline, Qt))
{
/* Use default color (same as foreground color). */
face->underline_p = 1;
+ face->underline_type = FACE_UNDER_LINE;
face->underline_defaulted_p = 1;
face->underline_color = 0;
}
- else if (STRINGP (attrs[LFACE_UNDERLINE_INDEX]))
+ else if (STRINGP (underline))
{
/* Use specified color. */
face->underline_p = 1;
+ face->underline_type = FACE_UNDER_LINE;
face->underline_defaulted_p = 0;
face->underline_color
- = load_color (f, face, attrs[LFACE_UNDERLINE_INDEX],
+ = load_color (f, face, underline,
LFACE_UNDERLINE_INDEX);
}
- else if (NILP (attrs[LFACE_UNDERLINE_INDEX]))
+ else if (NILP (underline))
{
face->underline_p = 0;
face->underline_defaulted_p = 0;
face->underline_color = 0;
}
+ else if (CONSP (underline))
+ {
+ /* `(:color COLOR :style STYLE)'.
+ STYLE being one of `line' or `wave'. */
+ face->underline_p = 1;
+ face->underline_color = 0;
+ face->underline_defaulted_p = 1;
+ face->underline_type = FACE_UNDER_LINE;
+
+ while (CONSP (underline))
+ {
+ Lisp_Object keyword, value;
+
+ keyword = XCAR (underline);
+ underline = XCDR (underline);
+
+ if (!CONSP (underline))
+ break;
+ value = XCAR (underline);
+ underline = XCDR (underline);
+
+ if (EQ (keyword, QCcolor))
+ {
+ if (EQ (value, Qforeground_color))
+ {
+ face->underline_defaulted_p = 1;
+ face->underline_color = 0;
+ }
+ else if (STRINGP (value))
+ {
+ face->underline_defaulted_p = 0;
+ face->underline_color = load_color (f, face, value,
+ LFACE_UNDERLINE_INDEX);
+ }
+ }
+ else if (EQ (keyword, QCstyle))
+ {
+ if (EQ (value, Qline))
+ face->underline_type = FACE_UNDER_LINE;
+ else if (EQ (value, Qwave))
+ face->underline_type = FACE_UNDER_WAVE;
+ }
+ }
+ }
overline = attrs[LFACE_OVERLINE_INDEX];
if (STRINGP (overline))
foreground_p ? FACE_TTY_DEFAULT_BG_COLOR : FACE_TTY_DEFAULT_FG_COLOR;
#endif
- xassert (idx == LFACE_FOREGROUND_INDEX || idx == LFACE_BACKGROUND_INDEX);
+ eassert (idx == LFACE_FOREGROUND_INDEX || idx == LFACE_BACKGROUND_INDEX);
XSETFRAME (frame, f);
color = face->lface[idx];
struct frame *f = cache->f;
/* Frame must be a termcap frame. */
- xassert (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f));
+ eassert (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f));
/* Allocate a new realized face. */
face = make_realized_face (attrs);
face->font_name = FRAME_MSDOS_P (cache->f) ? "ms-dos" : "tty";
#endif
- /* Map face attributes to TTY appearances. We map slant to
- dimmed text because we want italic text to appear differently
- and because dimmed text is probably used infrequently. */
+ /* Map face attributes to TTY appearances. */
weight = FONT_WEIGHT_NAME_NUMERIC (attrs[LFACE_WEIGHT_INDEX]);
slant = FONT_SLANT_NAME_NUMERIC (attrs[LFACE_SLANT_INDEX]);
if (weight > 100)
face->tty_bold_p = 1;
- if (weight < 100 || slant != 100)
- face->tty_dim_p = 1;
+ if (slant != 100)
+ face->tty_italic_p = 1;
if (!NILP (attrs[LFACE_UNDERLINE_INDEX]))
face->tty_underline_p = 1;
if (!NILP (attrs[LFACE_INVERSE_INDEX]))
The face returned is suitable for displaying ASCII characters. */
int
-face_at_buffer_position (struct window *w, EMACS_INT pos,
- EMACS_INT region_beg, EMACS_INT region_end,
- EMACS_INT *endptr, EMACS_INT limit,
+face_at_buffer_position (struct window *w, ptrdiff_t pos,
+ ptrdiff_t region_beg, ptrdiff_t region_end,
+ ptrdiff_t *endptr, ptrdiff_t limit,
int mouse, int base_face_id)
{
struct frame *f = XFRAME (w->frame);
ptrdiff_t i, noverlays;
Lisp_Object *overlay_vec;
Lisp_Object frame;
- EMACS_INT endpos;
+ ptrdiff_t endpos;
Lisp_Object propname = mouse ? Qmouse_face : Qface;
Lisp_Object limit1, end;
struct face *default_face;
/* W must display the current buffer. We could write this function
to use the frame and buffer of W, but right now it doesn't. */
- /* xassert (XBUFFER (w->buffer) == current_buffer); */
+ /* eassert (XBUFFER (w->buffer) == current_buffer); */
XSETFRAME (frame, f);
XSETFASTINT (position, pos);
/* Look at properties from overlays. */
{
- EMACS_INT next_overlay;
+ ptrdiff_t next_overlay;
GET_OVERLAYS_AT (pos, overlay_vec, noverlays, &next_overlay, 0);
if (next_overlay < endpos)
simply disregards the `face' properties of all overlays. */
int
-face_for_overlay_string (struct window *w, EMACS_INT pos,
- EMACS_INT region_beg, EMACS_INT region_end,
- EMACS_INT *endptr, EMACS_INT limit,
+face_for_overlay_string (struct window *w, ptrdiff_t pos,
+ ptrdiff_t region_beg, ptrdiff_t region_end,
+ ptrdiff_t *endptr, ptrdiff_t limit,
int mouse, Lisp_Object overlay)
{
struct frame *f = XFRAME (w->frame);
/* W must display the current buffer. We could write this function
to use the frame and buffer of W, but right now it doesn't. */
- /* xassert (XBUFFER (w->buffer) == current_buffer); */
+ /* eassert (XBUFFER (w->buffer) == current_buffer); */
XSETFRAME (frame, f);
XSETFASTINT (position, pos);
*endptr = endpos;
- default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
-
- /* Optimize common cases where we can use the default face. */
+ /* Optimize common case where we can use the default face. */
if (NILP (prop)
- && !(pos >= region_beg && pos < region_end))
+ && !(pos >= region_beg && pos < region_end)
+ && NILP (Vface_remapping_alist))
return DEFAULT_FACE_ID;
/* Begin with attributes from the default face. */
+ default_face = FACE_FROM_ID (f, lookup_basic_face (f, DEFAULT_FACE_ID));
memcpy (attrs, default_face->lface, sizeof attrs);
/* Merge in attributes specified via text properties. */
int
face_at_string_position (struct window *w, Lisp_Object string,
- EMACS_INT pos, EMACS_INT bufpos,
- EMACS_INT region_beg, EMACS_INT region_end,
- EMACS_INT *endptr, enum face_id base_face_id,
+ ptrdiff_t pos, ptrdiff_t bufpos,
+ ptrdiff_t region_beg, ptrdiff_t region_end,
+ ptrdiff_t *endptr, enum face_id base_face_id,
int mouse_p)
{
Lisp_Object prop, position, end, limit;
*endptr = -1;
base_face = FACE_FROM_ID (f, base_face_id);
- xassert (base_face);
+ eassert (base_face);
/* Optimize the default case that there is no face property and we
are not in the region. */
*/
int
-merge_faces (struct frame *f, Lisp_Object face_name, EMACS_INT face_id,
+merge_faces (struct frame *f, Lisp_Object face_name, int face_id,
int base_face_id)
{
Lisp_Object attrs[LFACE_VECTOR_SIZE];
CHECK_STRING (filename);
abspath = Fexpand_file_name (filename, Qnil);
- fp = fopen (SDATA (abspath), "rt");
+ fp = fopen (SSDATA (abspath), "rt");
if (fp)
{
char buf[512];
Tests
***********************************************************************/
-#if GLYPH_DEBUG
+#ifdef GLYPH_DEBUG
/* Print the contents of the realized face FACE to stderr. */
return Qnil;
}
-#endif /* GLYPH_DEBUG != 0 */
+#endif /* GLYPH_DEBUG */
\f
DEFSYM (QCcolor, ":color");
DEFSYM (QCline_width, ":line-width");
DEFSYM (QCstyle, ":style");
+ DEFSYM (Qline, "line");
+ DEFSYM (Qwave, "wave");
DEFSYM (Qreleased_button, "released-button");
DEFSYM (Qpressed_button, "pressed-button");
DEFSYM (Qnormal, "normal");
defsubr (&Sinternal_set_alternative_font_family_alist);
defsubr (&Sinternal_set_alternative_font_registry_alist);
defsubr (&Sface_attributes_as_vector);
-#if GLYPH_DEBUG
+#ifdef GLYPH_DEBUG
defsubr (&Sdump_face);
defsubr (&Sshow_face_resources);
#endif /* GLYPH_DEBUG */
#endif
DEFVAR_LISP ("font-list-limit", Vfont_list_limit,
- doc: /* *Limit for font matching.
+ doc: /* Limit for font matching.
If an integer > 0, font matching functions won't load more than
that number of fonts when searching for a matching font. */);
Vfont_list_limit = make_number (DEFAULT_FONT_LIST_LIMIT);
Vface_new_frame_defaults = Qnil;
DEFVAR_LISP ("face-default-stipple", Vface_default_stipple,
- doc: /* *Default stipple pattern used on monochrome displays.
+ doc: /* Default stipple pattern used on monochrome displays.
This stipple pattern is used on monochrome displays
instead of shades of gray for a face background color.
See `set-face-stipple' for possible values for this variable. */);
- Vface_default_stipple = make_pure_c_string ("gray3");
+ Vface_default_stipple = build_pure_c_string ("gray3");
DEFVAR_LISP ("tty-defined-color-alist", Vtty_defined_color_alist,
doc: /* An alist of defined terminal colors and their RGB values.
doc: /* Alist of face remappings.
Each element is of the form:
- (FACE REPLACEMENT...),
+ (FACE . REPLACEMENT),
+
+which causes display of the face FACE to use REPLACEMENT instead.
+REPLACEMENT is a face specification, i.e. one of the following:
-which causes display of the face FACE to use REPLACEMENT... instead.
-REPLACEMENT... is interpreted the same way as the value of a `face'
-text property: it may be (1) A face name, (2) A list of face names,
-(3) A property-list of face attribute/value pairs, or (4) A list of
-face names or lists containing face attribute/value pairs.
+ (1) a face name
+ (2) a property list of attribute/value pairs, or
+ (3) a list in which each element has the form of (1) or (2).
-Multiple entries in REPLACEMENT... are merged together to form the final
-result, with faces or attributes earlier in the list taking precedence
-over those that are later.
+List values for REPLACEMENT are merged to form the final face
+specification, with earlier entries taking precedence, in the same as
+as in the `face' text property.
-Face-name remapping cycles are suppressed; recursive references use the
-underlying face instead of the remapped face. So a remapping of the form:
+Face-name remapping cycles are suppressed; recursive references use
+the underlying face instead of the remapped face. So a remapping of
+the form:
(FACE EXTRA-FACE... FACE)
(FACE (FACE-ATTR VAL ...) FACE)
-will cause EXTRA-FACE... or (FACE-ATTR VAL ...) to be _merged_ with the
-existing definition of FACE. Note that for the default face, this isn't
-necessary, as every face inherits from the default face.
+causes EXTRA-FACE... or (FACE-ATTR VAL ...) to be _merged_ with the
+existing definition of FACE. Note that this isn't necessary for the
+default face, since every face inherits from the default face.
-Making this variable buffer-local is a good way to allow buffer-specific
-face definitions. For instance, the mode my-mode could define a face
-`my-mode-default', and then in the mode setup function, do:
+If this variable is made buffer-local, the face remapping takes effect
+only in that buffer. For instance, the mode my-mode could define a
+face `my-mode-default', and then in the mode setup function, do:
(set (make-local-variable 'face-remapping-alist)
'((default my-mode-default)))).