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
used to fill in unspecified attributes of the default face. */
#include <config.h>
-#include <stdio.h>
+#include "sysstdio.h"
#include <sys/types.h>
#include <sys/stat.h>
-#include <stdio.h> /* This needs to be before termchar.h */
#include "lisp.h"
#include "character.h"
#undef FRAME_X_DISPLAY_INFO
#define FRAME_X_DISPLAY_INFO FRAME_W32_DISPLAY_INFO
#define x_display_info w32_display_info
-#define check_x check_w32
#define GCGraphicsExposures 0
#endif /* HAVE_NTGUI */
#undef FRAME_X_DISPLAY_INFO
#define FRAME_X_DISPLAY_INFO FRAME_NS_DISPLAY_INFO
#define x_display_info ns_display_info
-#define check_x check_ns
#define GCGraphicsExposures 0
#endif /* HAVE_NS */
#endif /* HAVE_WINDOW_SYSTEM */
struct face *);
static struct face *realize_x_face (struct face_cache *, Lisp_Object *);
static struct face *realize_tty_face (struct face_cache *, Lisp_Object *);
-static int realize_basic_faces (struct frame *);
-static int realize_default_face (struct frame *);
+static bool realize_basic_faces (struct frame *);
+static bool realize_default_face (struct frame *);
static void realize_named_face (struct frame *, Lisp_Object, int);
static struct face_cache *make_face_cache (struct frame *);
static void clear_face_gcs (struct face_cache *);
\(WIDTH + 7)/8 bytes. */)
(Lisp_Object object)
{
- int pixmap_p = 0;
+ bool pixmap_p = 0;
if (STRINGP (object))
/* If OBJECT is a string, it's a file name. */
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));
struct frame *f;
int size, avgwidth IF_LINT (= 0);
- check_x ();
+ check_window_system (NULL);
CHECK_STRING (pattern);
if (! NILP (maximum))
if (!NILP (width))
CHECK_NUMBER (width);
- /* We can't simply call check_x_frame because this function may be
- called before any frame is created. */
+ /* We can't simply call decode_window_system_frame because
+ this function may be called before any frame is created. */
f = decode_live_frame (frame);
if (! FRAME_WINDOW_P (f))
{
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));
}
else if (EQ (attr, QCunderline))
{
- int valid_p = 0;
+ bool valid_p = 0;
if (UNSPECIFIEDP (value) || IGNORE_DEFFACE_P (value))
valid_p = 1;
}
else if (EQ (attr, QCbox))
{
- int valid_p;
+ bool valid_p;
/* Allow t meaning a simple box of width 1 in foreground color
of the face. */
#endif /* HAVE_WINDOW_SYSTEM */
else if (EQ (face, Qmenu))
{
- /* Indicate that we have to update the menu bar when
- realizing faces on FRAME. FRAME t change the
- default for new frames. We do this by setting
- setting the flag in new face caches */
+ /* Indicate that we have to update the menu bar when realizing
+ faces on FRAME. FRAME t change the default for new frames.
+ We do this by setting the flag in new face caches. */
if (FRAMEP (frame))
{
struct frame *f = XFRAME (frame);
ASET (lface, LFACE_FONT_INDEX, font);
}
f->default_face_done_p = 0;
- Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, font), Qnil));
+ Fmodify_frame_parameters (frame, list1 (Fcons (Qfont, font)));
}
}
-
-/* Get the value of X resource RESOURCE, class CLASS for the display
- of frame FRAME. This is here because ordinary `x-get-resource'
- doesn't take a frame argument. */
-
DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource,
- Sinternal_face_x_get_resource, 3, 3, 0, doc: /* */)
+ Sinternal_face_x_get_resource, 2, 3, 0,
+ doc: /* Get the value of X resource RESOURCE, class CLASS.
+Returned value is for the display of frame FRAME. If FRAME is not
+specified or nil, use selected frame. This function exists because
+ordinary `x-get-resource' doesn't take a frame argument. */)
(Lisp_Object resource, Lisp_Object class, Lisp_Object frame)
{
Lisp_Object value = Qnil;
+ struct frame *f;
+
CHECK_STRING (resource);
CHECK_STRING (class);
- CHECK_LIVE_FRAME (frame);
+ f = decode_live_frame (frame);
block_input ();
- value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)),
+ value = display_x_get_resource (FRAME_X_DISPLAY_INFO (f),
resource, class, Qnil, Qnil);
unblock_input ();
return value;
Lisp_Object lface = lface_from_face_name (f, Qmenu, 1);
struct face *face = FACE_FROM_ID (f, MENU_FACE_ID);
const char *myname = SSDATA (Vx_resource_name);
- int changed_p = 0;
+ bool changed_p = 0;
#ifdef USE_MOTIF
const char *popup_path = "popup_menu";
#else
CHECK_SYMBOL (attr);
- if (EQ (attr, QCunderline))
- result = Fcons (Qt, Fcons (Qnil, Qnil));
- else if (EQ (attr, QCoverline))
- result = Fcons (Qt, Fcons (Qnil, Qnil));
- else if (EQ (attr, QCstrike_through))
- result = Fcons (Qt, Fcons (Qnil, Qnil));
- else if (EQ (attr, QCinverse_video) || EQ (attr, QCreverse_video))
- result = Fcons (Qt, Fcons (Qnil, Qnil));
+ if (EQ (attr, QCunderline) || EQ (attr, QCoverline)
+ || EQ (attr, QCstrike_through)
+ || EQ (attr, QCinverse_video) || EQ (attr, QCreverse_video))
+ result = list2 (Qt, Qnil);
return result;
}
&& newface->font)
{
Lisp_Object name = newface->font->props[FONT_NAME_INDEX];
- Fmodify_frame_parameters (frame, Fcons (Fcons (Qfont, name),
- Qnil));
+ Fmodify_frame_parameters (frame, list1 (Fcons (Qfont, name)));
}
if (STRINGP (gvec[LFACE_FOREGROUND_INDEX]))
Fmodify_frame_parameters (frame,
- Fcons (Fcons (Qforeground_color,
- gvec[LFACE_FOREGROUND_INDEX]),
- Qnil));
+ list1 (Fcons (Qforeground_color,
+ gvec[LFACE_FOREGROUND_INDEX])));
if (STRINGP (gvec[LFACE_BACKGROUND_INDEX]))
Fmodify_frame_parameters (frame,
- Fcons (Fcons (Qbackground_color,
- gvec[LFACE_BACKGROUND_INDEX]),
- Qnil));
+ list1 (Fcons (Qbackground_color,
+ gvec[LFACE_BACKGROUND_INDEX])));
}
}
all attributes are `equal'. Tries to be fast because this function
is called quite often. */
-static int
+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,
all attributes are `equal'. Tries to be fast because this function
is called quite often. */
-static int
+static bool
lface_equal_p (Lisp_Object *v1, Lisp_Object *v2)
{
- int i, equal_p = 1;
+ int i;
+ bool equal_p = 1;
for (i = 1; i < LFACE_VECTOR_SIZE && equal_p; ++i)
equal_p = face_attr_equal_p (v1[i], v2[i]);
struct frame *f;
Lisp_Object lface1, lface2;
- /* Don't use check_x_frame here because this function is called
- before X frames exist. At that time, if FRAME is nil,
+ /* Don't use decode_window_system_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);
static struct face_cache *
make_face_cache (struct frame *f)
{
- struct face_cache *c;
- int size;
+ struct face_cache *c = xmalloc (sizeof *c);
- c = xzalloc (sizeof *c);
- size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
- c->buckets = xzalloc (size);
+ c->buckets = xzalloc (FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets);
c->size = 50;
+ c->used = 0;
c->faces_by_id = xmalloc (c->size * sizeof *c->faces_by_id);
c->f = f;
c->menu_face_changed_p = menu_face_changed_default;
of F don't contain enough information needed to realize the default
face. */
-static int
+static bool
realize_basic_faces (struct frame *f)
{
- int success_p = 0;
+ bool success_p = 0;
ptrdiff_t count = SPECPDL_INDEX ();
/* Block input here so that we won't be surprised by an X expose
specified, make it fully-specified. Attributes of the default face
that are not explicitly specified are taken from frame parameters. */
-static int
+static bool
realize_default_face (struct frame *f)
{
struct face_cache *c = FRAME_FACE_CACHE (f);
/* 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. */
- /* eassert (XBUFFER (w->buffer) == current_buffer); */
+ /* eassert (XBUFFER (w->contents) == current_buffer); */
XSETFASTINT (position, pos);
/* Get the `face' or `mouse_face' text property at POS, and
determine the next position at which the property changes. */
- prop = Fget_text_property (position, propname, w->buffer);
+ prop = Fget_text_property (position, propname, w->contents);
XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
- end = Fnext_single_property_change (position, propname, w->buffer, limit1);
+ end = Fnext_single_property_change (position, propname, w->contents, limit1);
if (INTEGERP (end))
endpos = XINT (end);
/* 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. */
- /* eassert (XBUFFER (w->buffer) == current_buffer); */
+ /* eassert (XBUFFER (w->contents) == current_buffer); */
XSETFASTINT (position, pos);
/* Get the `face' or `mouse_face' text property at POS, and
determine the next position at which the property changes. */
- prop = Fget_text_property (position, propname, w->buffer);
+ prop = Fget_text_property (position, propname, w->contents);
XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
- end = Fnext_single_property_change (position, propname, w->buffer, limit1);
+ end = Fnext_single_property_change (position, propname, w->contents, limit1);
if (INTEGERP (end))
endpos = XINT (end);
CHECK_STRING (filename);
abspath = Fexpand_file_name (filename, Qnil);
- fp = fopen (SSDATA (abspath), "rt");
+ block_input ();
+ fp = emacs_fopen (SSDATA (abspath), "rt");
if (fp)
{
char buf[512];
int red, green, blue;
int num;
- block_input ();
-
while (fgets (buf, sizeof (buf), fp) != NULL) {
if (sscanf (buf, "%u %u %u %n", &red, &green, &blue, &num) == 3)
{
- char *name = buf + num;
- num = strlen (name) - 1;
- if (num >= 0 && name[num] == '\n')
- name[num] = 0;
- cmap = Fcons (Fcons (build_string (name),
#ifdef HAVE_NTGUI
- make_number (RGB (red, green, blue))),
+ int color = RGB (red, green, blue);
#else
- make_number ((red << 16) | (green << 8) | blue)),
+ int color = (red << 16) | (green << 8) | blue;
#endif
+ char *name = buf + num;
+ ptrdiff_t len = strlen (name);
+ len -= 0 < len && name[len - 1] == '\n';
+ cmap = Fcons (Fcons (make_string (name, len), make_number (color)),
cmap);
}
}
fclose (fp);
-
- unblock_input ();
}
-
+ unblock_input ();
return cmap;
}
#endif
DEFSYM (Qtty_color_alist, "tty-color-alist");
DEFSYM (Qscalable_fonts_allowed, "scalable-fonts-allowed");
- Vparam_value_alist = Fcons (Fcons (Qnil, Qnil), Qnil);
+ Vparam_value_alist = list1 (Fcons (Qnil, Qnil));
staticpro (&Vparam_value_alist);
Vface_alternative_font_family_alist = Qnil;
staticpro (&Vface_alternative_font_family_alist);