/* xfaces.c -- "Face" primitives.
-Copyright (C) 1993-1994, 1998-2012 Free Software Foundation, Inc.
+Copyright (C) 1993-1994, 1998-2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
merging faces of that character, that face is `realized'. The
realization process maps face attributes to what is physically
available on the system where Emacs runs. The result is a
- `realized face' in form of a struct face which is stored in the
+ `realized face' in the form of a struct face which is stored in the
face cache of the frame on which it was realized.
Face realization is done in the context of the character to display
Lisp_Object Qnormal;
Lisp_Object Qbold;
static Lisp_Object Qline, Qwave;
-static Lisp_Object Qultra_light, Qreverse_oblique, Qreverse_italic;
Lisp_Object Qextra_light, Qlight;
Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold;
Lisp_Object Qoblique;
Lisp_Object Qitalic;
-static Lisp_Object Qultra_condensed, Qextra_condensed;
-Lisp_Object Qcondensed;
-static Lisp_Object Qsemi_condensed, Qsemi_expanded, Qextra_expanded;
-Lisp_Object Qexpanded;
-static Lisp_Object Qultra_expanded;
static Lisp_Object Qreleased_button, Qpressed_button;
static Lisp_Object QCstyle, QCcolor, QCline_width;
Lisp_Object Qunspecified; /* used in dosfns.c */
static Lisp_Object Qscalable_fonts_allowed;
-#define DEFAULT_FONT_LIST_LIMIT 100
-
/* The symbols `foreground-color' and `background-color' which can be
used as part of a `face' property. This is for compatibility with
Emacs 20.2. */
}
#endif /* HAVE_NS */
-/* 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
- CHECK_LIVE_FRAME. This is here because it's a frequent pattern in
- Lisp function definitions. */
-
-static struct frame *
-frame_or_selected_frame (Lisp_Object frame, int nparam)
-{
- if (NILP (frame))
- frame = selected_frame;
-
- CHECK_LIVE_FRAME (frame);
- return XFRAME (frame);
-}
-
-\f
/***********************************************************************
Frames and faces
***********************************************************************/
If FRAME is nil or omitted, use the selected frame. */)
(Lisp_Object color, Lisp_Object frame)
{
- struct frame *f;
-
CHECK_STRING (color);
- if (NILP (frame))
- frame = selected_frame;
- else
- CHECK_FRAME (frame);
- f = XFRAME (frame);
- return face_color_gray_p (f, SSDATA (color)) ? Qt : Qnil;
+ return (face_color_gray_p (decode_any_frame (frame), SSDATA (color))
+ ? Qt : Qnil);
}
COLOR must be a valid color name. */)
(Lisp_Object color, Lisp_Object frame, Lisp_Object background_p)
{
- struct frame *f;
-
CHECK_STRING (color);
- if (NILP (frame))
- frame = selected_frame;
- else
- CHECK_FRAME (frame);
- f = XFRAME (frame);
- if (face_color_supported_p (f, SSDATA (color), !NILP (background_p)))
- return Qt;
- return Qnil;
+ return (face_color_supported_p (decode_any_frame (frame),
+ SSDATA (color), !NILP (background_p))
+ ? Qt : Qnil);
}
try to emulate gray colors with a stipple from Vface_default_stipple. */
static void
-load_face_colors (struct frame *f, struct face *face, Lisp_Object *attrs)
+load_face_colors (struct frame *f, struct face *face,
+ Lisp_Object attrs[LFACE_VECTOR_SIZE])
{
Lisp_Object fg, bg;
for (i = nfonts - 1; i >= 0; --i)
{
Lisp_Object font = AREF (vec, i);
- Lisp_Object v = Fmake_vector (make_number (8), Qnil);
+ Lisp_Object v = make_uninit_vector (8);
int point;
Lisp_Object spacing;
ASET (v, 0, AREF (font, FONT_FAMILY_INDEX));
ASET (v, 1, FONT_WIDTH_SYMBOLIC (font));
point = PIXEL_TO_POINT (XINT (AREF (font, FONT_SIZE_INDEX)) * 10,
- XFRAME (frame)->resy);
+ FRAME_RES_Y (XFRAME (frame)));
ASET (v, 2, make_number (point));
ASET (v, 3, FONT_WEIGHT_SYMBOLIC (font));
ASET (v, 4, FONT_SLANT_SYMBOLIC (font));
/* We can't simply call check_x_frame because this function may be
called before any frame is created. */
- if (NILP (frame))
- frame = selected_frame;
- f = frame_or_selected_frame (frame, 2);
+ f = decode_live_frame (frame);
if (! FRAME_WINDOW_P (f))
{
/* Perhaps we have not yet created any frame. */
frame = Qnil;
face = Qnil;
}
+ else
+ XSETFRAME (frame, f);
/* Determine the width standard for comparison with the fonts we find. */
/* Check consistency of Lisp face attribute vector ATTRS. */
static void
-check_lface_attrs (Lisp_Object *attrs)
+check_lface_attrs (Lisp_Object attrs[LFACE_VECTOR_SIZE])
{
eassert (UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX])
|| IGNORE_DEFFACE_P (attrs[LFACE_FAMILY_INDEX])
static int
get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name,
- Lisp_Object *attrs, int signal_p)
+ Lisp_Object attrs[LFACE_VECTOR_SIZE],
+ int signal_p)
{
Lisp_Object lface;
static int
get_lface_attributes (struct frame *f, Lisp_Object face_name,
- Lisp_Object *attrs, int signal_p,
+ Lisp_Object attrs[LFACE_VECTOR_SIZE], int signal_p,
struct named_merge_point *named_merge_points)
{
Lisp_Object face_remapping;
specified, i.e. are non-nil. */
static int
-lface_fully_specified_p (Lisp_Object *attrs)
+lface_fully_specified_p (Lisp_Object attrs[LFACE_VECTOR_SIZE])
{
int i;
if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface)))
{
- int pt = PIXEL_TO_POINT (font->pixel_size * 10, f->resy);
+ int pt = PIXEL_TO_POINT (font->pixel_size * 10, FRAME_RES_Y (f));
eassert (pt > 0);
ASET (lface, LFACE_HEIGHT_INDEX, make_number (pt));
Lisp_Object key, val, list;
list = value;
+ /* FIXME? This errs on the side of acceptance. Eg it accepts:
+ (defface foo '((t :underline 'foo) "doc")
+ Maybe this is intentional, maybe it isn't.
+ Non-nil symbols other than t are not documented as being valid.
+ Eg compare with inverse-video, which explicitly rejects them.
+ */
valid_p = 1;
while (!NILP (CAR_SAFE(list)))
frames). If FRAME is omitted or nil, use the selected frame. */)
(Lisp_Object symbol, Lisp_Object keyword, Lisp_Object frame)
{
- Lisp_Object lface, value = Qnil;
+ struct frame *f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
+ Lisp_Object lface = lface_from_face_name (f, symbol, 1), value = Qnil;
CHECK_SYMBOL (symbol);
CHECK_SYMBOL (keyword);
- if (EQ (frame, Qt))
- lface = lface_from_face_name (NULL, symbol, 1);
- else
- {
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- lface = lface_from_face_name (XFRAME (frame), symbol, 1);
- }
-
if (EQ (keyword, QCfamily))
value = LFACE_FAMILY (lface);
else if (EQ (keyword, QCfoundry))
}
else
{
- struct frame *f = frame_or_selected_frame (frame, 1);
+ struct frame *f = decode_live_frame (frame);
int face_id = lookup_named_face (f, face, 1);
struct face *fface = FACE_FROM_ID (f, face_id);
struct frame *f;
Lisp_Object lface1, lface2;
- if (EQ (frame, Qt))
- f = NULL;
- else
- /* Don't use check_x_frame here because this function is called
- before X frames exist. At that time, if FRAME is nil,
- selected_frame will be used which is the frame dumped with
- Emacs. That frame is not an X frame. */
- f = frame_or_selected_frame (frame, 2);
+ /* Don't use check_x_frame here because this function is called
+ before X frames exist. At that time, if FRAME is nil,
+ selected_frame will be used which is the frame dumped with
+ Emacs. That frame is not an X frame. */
+ f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
lface1 = lface_from_face_name (f, face1, 1);
lface2 = lface_from_face_name (f, face2, 1);
If FRAME is omitted or nil, use the selected frame. */)
(Lisp_Object face, Lisp_Object frame)
{
- struct frame *f;
- Lisp_Object lface;
+ struct frame *f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
+ Lisp_Object lface = lface_from_face_name (f, face, 1);
int i;
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
-
- if (EQ (frame, Qt))
- lface = lface_from_face_name (NULL, face, 1);
- else
- lface = lface_from_face_name (f, face, 1);
-
for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
if (!UNSPECIFIEDP (AREF (lface, i)))
break;
For internal use only. */)
(Lisp_Object frame)
{
- struct frame *f = frame_or_selected_frame (frame, 0);
- return f->face_alist;
+ return decode_live_frame (frame)->face_alist;
}
If FRAME is unspecified or nil, the current frame is used. */)
(Lisp_Object color1, Lisp_Object color2, Lisp_Object frame)
{
- struct frame *f;
+ struct frame *f = decode_live_frame (frame);
XColor cdef1, cdef2;
- if (NILP (frame))
- frame = selected_frame;
- CHECK_LIVE_FRAME (frame);
- f = XFRAME (frame);
-
if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1))
&& !(STRINGP (color1) && defined_color (f, SSDATA (color1), &cdef1, 0)))
signal_error ("Invalid color", color1);
\(2) `close in spirit' to what the attributes specify, if not exact. */
static int
-x_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs,
+x_supports_face_attributes_p (struct frame *f,
+ Lisp_Object attrs[LFACE_VECTOR_SIZE],
struct face *def_face)
{
Lisp_Object *def_attrs = def_face->lface;
substitution of a `dim' face for italic. */
static int
-tty_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs,
+tty_supports_face_attributes_p (struct frame *f,
+ Lisp_Object attrs[LFACE_VECTOR_SIZE],
struct face *def_face)
{
int weight, slant;
{
if (STRINGP (val))
return 0; /* ttys can't use colored underlines */
+ else if (EQ (CAR_SAFE (val), QCstyle) && EQ (CAR_SAFE (CDR_SAFE (val)), Qwave))
+ return 0; /* ttys can't use wave underlines */
else if (face_attr_equal_p (val, def_attrs[LFACE_UNDERLINE_INDEX]))
return 0; /* same as default */
else
else
{
/* Find any frame on DISPLAY. */
- Lisp_Object fl_tail;
+ Lisp_Object tail;
frame = Qnil;
- for (fl_tail = Vframe_list; CONSP (fl_tail); fl_tail = XCDR (fl_tail))
- {
- frame = XCAR (fl_tail);
- if (!NILP (Fequal (Fcdr (Fassq (Qdisplay,
- XFRAME (frame)->param_alist)),
- display)))
- break;
- }
+ FOR_EACH_FRAME (tail, frame)
+ if (!NILP (Fequal (Fcdr (Fassq (Qdisplay,
+ XFRAME (frame)->param_alist)),
+ display)))
+ break;
}
CHECK_LIVE_FRAME (frame);
attribute of ATTRS doesn't name a fontset. */
static int
-face_fontset (Lisp_Object *attrs)
+face_fontset (Lisp_Object attrs[LFACE_VECTOR_SIZE])
{
Lisp_Object name;
face. Value is a pointer to the newly created realized face. */
static struct face *
-realize_face (struct face_cache *cache, Lisp_Object *attrs, int former_face_id)
+realize_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE],
+ int former_face_id)
{
struct face *face;
created realized face. */
static struct face *
-realize_x_face (struct face_cache *cache, Lisp_Object *attrs)
+realize_x_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE])
{
struct face *face = NULL;
#ifdef HAVE_WINDOW_SYSTEM
face->underline_defaulted_p = 1;
face->underline_type = FACE_UNDER_LINE;
+ /* FIXME? This is also not robust about checking the precise form.
+ See comments in Finternal_set_lisp_face_attribute. */
while (CONSP (underline))
{
Lisp_Object keyword, value;
Value is a pointer to the newly created realized face. */
static struct face *
-realize_tty_face (struct face_cache *cache, Lisp_Object *attrs)
+realize_tty_face (struct face_cache *cache,
+ Lisp_Object attrs[LFACE_VECTOR_SIZE])
{
struct face *face;
int weight, slant;
struct frame *f = XFRAME (WINDOW_FRAME (w));
Lisp_Object attrs[LFACE_VECTOR_SIZE];
struct face *base_face;
- int multibyte_p = STRING_MULTIBYTE (string);
+ bool multibyte_p = STRING_MULTIBYTE (string);
Lisp_Object prop_name = mouse_p ? Qmouse_face : Qface;
/* Get the value of the face property at the current position within
DEFSYM (Qreleased_button, "released-button");
DEFSYM (Qpressed_button, "pressed-button");
DEFSYM (Qnormal, "normal");
- DEFSYM (Qultra_light, "ultra-light");
DEFSYM (Qextra_light, "extra-light");
DEFSYM (Qlight, "light");
DEFSYM (Qsemi_light, "semi-light");
DEFSYM (Qultra_bold, "ultra-bold");
DEFSYM (Qoblique, "oblique");
DEFSYM (Qitalic, "italic");
- DEFSYM (Qreverse_oblique, "reverse-oblique");
- DEFSYM (Qreverse_italic, "reverse-italic");
- DEFSYM (Qultra_condensed, "ultra-condensed");
- DEFSYM (Qextra_condensed, "extra-condensed");
- DEFSYM (Qcondensed, "condensed");
- DEFSYM (Qsemi_condensed, "semi-condensed");
- DEFSYM (Qsemi_expanded, "semi-expanded");
- DEFSYM (Qexpanded, "expanded");
- DEFSYM (Qextra_expanded, "extra-expanded");
- DEFSYM (Qultra_expanded, "ultra-expanded");
DEFSYM (Qbackground_color, "background-color");
DEFSYM (Qforeground_color, "foreground-color");
DEFSYM (Qunspecified, "unspecified");
defsubr (&Sdump_colors);
#endif
- DEFVAR_LISP ("font-list-limit", Vfont_list_limit,
- 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);
-
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;