summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-08-04 06:07:05 +0000
committerRichard M. Stallman <rms@gnu.org>1997-08-04 06:07:05 +0000
commitd8a559b711a30d6e278a1a86bdd814298f65fe10 (patch)
tree4bacc2a2ea6b2e117d0e0916697e2fb8b1c91f15 /src
parentd36e64f91dc66ec62eb8e97072a7d55fa121eac2 (diff)
downloademacs-d8a559b711a30d6e278a1a86bdd814298f65fe10.tar.gz
(merge_face_list): New function.
(compute_char_face): Use merge_face_list. Allow (foreground-color . COLOR) and (background-color . COLOR) in place of a face.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c138
1 files changed, 66 insertions, 72 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 5d97fc37a06..d393a60f23b 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -172,6 +172,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;
/* Allocating, copying, and comparing struct faces. */
@@ -386,7 +389,7 @@ load_color (f, name)
CHECK_STRING (name, 0);
/* if the colormap is full, defined_color will return a best match
to the values in an an existing cell. */
- result = defined_color(f, (char *) XSTRING (name)->data, &color, 1);
+ result = defined_color (f, (char *) XSTRING (name)->data, &color, 1);
if (! result)
Fsignal (Qerror, Fcons (build_string ("undefined color"),
Fcons (name, Qnil)));
@@ -980,101 +983,92 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr, limit, mouse)
compute_base_face (f, &face);
- if (CONSP (prop))
+ 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++)
{
- /* We have a list of faces, merge them in reverse order */
- Lisp_Object length;
- int len;
- Lisp_Object *faces;
+ Lisp_Object oend;
+ int oendpos;
+
+ 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;
+ }
+
+ if (pos >= region_beg && pos < region_end)
+ {
+ if (region_end < endpos)
+ endpos = region_end;
+ if (region_face >= 0 && region_face < next_face_id)
+ merge_faces (FRAME_PARAM_FACES (f)[region_face], &face);
+ }
+
+ *endptr = endpos;
+
+ 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 */
+ /* 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);
- }
+ /* So that we can merge them in the reverse order. */
}
- else if (!NILP (prop))
+ else
{
- 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);
+ faces = (Lisp_Object *) alloca (sizeof (Lisp_Object));
+ faces[0] = prop;
+ len = 1;
}
- noverlays = sort_overlays (overlay_vec, noverlays, w);
-
- /* Now merge the overlay data in that order. */
- for (i = 0; i < noverlays; i++)
+ for (j = len - 1; j >= 0; j--)
{
- prop = Foverlay_get (overlay_vec[i], propname);
- if (CONSP (prop))
+ if (CONSP (faces[j]))
{
- /* We have a list of faces, merge them in reverse order */
- Lisp_Object length;
- int len;
- Lisp_Object *faces;
-
- 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 */
- 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);
- }
+ 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 if (!NILP (prop))
+ else
{
- Lisp_Object oend;
- int oendpos;
-
- facecode = face_name_id_number (f, prop);
+ 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);
-
- oend = OVERLAY_END (overlay_vec[i]);
- oendpos = OVERLAY_POSITION (oend);
- if (oendpos < endpos)
- endpos = oendpos;
+ merge_faces (FRAME_PARAM_FACES (f) [facecode], face);
}
}
-
- if (pos >= region_beg && pos < region_end)
- {
- if (region_end < endpos)
- endpos = region_end;
- if (region_face >= 0 && region_face < next_face_id)
- merge_faces (FRAME_PARAM_FACES (f)[region_face], &face);
- }
-
- *endptr = endpos;
-
- return intern_computed_face (f, &face);
}
+
/* Recompute the GC's for the default and modeline faces.
We call this after changing frame parameters on which those GC's