diff options
| author | Richard M. Stallman | 1997-08-04 06:07:05 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-08-04 06:07:05 +0000 |
| commit | 18195655171cb15b350439de2404e2070aaa8574 (patch) | |
| tree | 9024787de644144efedf3f9e5ec0c48041779bd4 /src | |
| parent | 4fd017e78e2509b93f282c4a577a2a950ab954eb (diff) | |
| download | emacs-18195655171cb15b350439de2404e2070aaa8574.tar.gz emacs-18195655171cb15b350439de2404e2070aaa8574.zip | |
(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.c | 138 |
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 * */ ); | |||
| 172 | static int intern_computed_face ( /* FRAME_PTR, struct face * */ ); | 172 | static int intern_computed_face ( /* FRAME_PTR, struct face * */ ); |
| 173 | static void ensure_face_ready ( /* FRAME_PTR, int id */ ); | 173 | static void ensure_face_ready ( /* FRAME_PTR, int id */ ); |
| 174 | void recompute_basic_faces ( /* FRAME_PTR f */ ); | 174 | void recompute_basic_faces ( /* FRAME_PTR f */ ); |
| 175 | static void merge_face_list ( /* FRAME_PTR, struct face *, Lisp_Object */ ); | ||
| 176 | |||
| 177 | extern Lisp_Object Qforeground_color, Qbackground_color; | ||
| 175 | 178 | ||
| 176 | /* Allocating, copying, and comparing struct faces. */ | 179 | /* Allocating, copying, and comparing struct faces. */ |
| 177 | 180 | ||
| @@ -386,7 +389,7 @@ load_color (f, name) | |||
| 386 | CHECK_STRING (name, 0); | 389 | CHECK_STRING (name, 0); |
| 387 | /* if the colormap is full, defined_color will return a best match | 390 | /* if the colormap is full, defined_color will return a best match |
| 388 | to the values in an an existing cell. */ | 391 | to the values in an an existing cell. */ |
| 389 | result = defined_color(f, (char *) XSTRING (name)->data, &color, 1); | 392 | result = defined_color (f, (char *) XSTRING (name)->data, &color, 1); |
| 390 | if (! result) | 393 | if (! result) |
| 391 | Fsignal (Qerror, Fcons (build_string ("undefined color"), | 394 | Fsignal (Qerror, Fcons (build_string ("undefined color"), |
| 392 | Fcons (name, Qnil))); | 395 | Fcons (name, Qnil))); |
| @@ -980,101 +983,92 @@ compute_char_face (f, w, pos, region_beg, region_end, endptr, limit, mouse) | |||
| 980 | 983 | ||
| 981 | compute_base_face (f, &face); | 984 | compute_base_face (f, &face); |
| 982 | 985 | ||
| 983 | if (CONSP (prop)) | 986 | merge_face_list (f, &face, prop); |
| 987 | |||
| 988 | noverlays = sort_overlays (overlay_vec, noverlays, w); | ||
| 989 | |||
| 990 | /* Now merge the overlay data in that order. */ | ||
| 991 | for (i = 0; i < noverlays; i++) | ||
| 984 | { | 992 | { |
| 985 | /* We have a list of faces, merge them in reverse order */ | 993 | Lisp_Object oend; |
| 986 | Lisp_Object length; | 994 | int oendpos; |
| 987 | int len; | 995 | |
| 988 | Lisp_Object *faces; | 996 | prop = Foverlay_get (overlay_vec[i], propname); |
| 997 | merge_face_list (f, &face, prop); | ||
| 998 | |||
| 999 | oend = OVERLAY_END (overlay_vec[i]); | ||
| 1000 | oendpos = OVERLAY_POSITION (oend); | ||
| 1001 | if (oendpos < endpos) | ||
| 1002 | endpos = oendpos; | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | if (pos >= region_beg && pos < region_end) | ||
| 1006 | { | ||
| 1007 | if (region_end < endpos) | ||
| 1008 | endpos = region_end; | ||
| 1009 | if (region_face >= 0 && region_face < next_face_id) | ||
| 1010 | merge_faces (FRAME_PARAM_FACES (f)[region_face], &face); | ||
| 1011 | } | ||
| 1012 | |||
| 1013 | *endptr = endpos; | ||
| 1014 | |||
| 1015 | return intern_computed_face (f, &face); | ||
| 1016 | } | ||
| 1017 | |||
| 1018 | static void | ||
| 1019 | merge_face_list (f, face, prop) | ||
| 1020 | FRAME_PTR f; | ||
| 1021 | struct face *face; | ||
| 1022 | Lisp_Object prop; | ||
| 1023 | { | ||
| 1024 | Lisp_Object length; | ||
| 1025 | int len; | ||
| 1026 | Lisp_Object *faces; | ||
| 1027 | int j; | ||
| 1028 | |||
| 1029 | if (CONSP (prop) | ||
| 1030 | && ! STRINGP (XCONS (prop)->cdr)) | ||
| 1031 | { | ||
| 1032 | /* We have a list of faces, merge them in reverse order. */ | ||
| 989 | 1033 | ||
| 990 | length = Fsafe_length (prop); | 1034 | length = Fsafe_length (prop); |
| 991 | len = XFASTINT (length); | 1035 | len = XFASTINT (length); |
| 992 | 1036 | ||
| 993 | /* Put them into an array */ | 1037 | /* Put them into an array. */ |
| 994 | faces = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); | 1038 | faces = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); |
| 995 | for (j = 0; j < len; j++) | 1039 | for (j = 0; j < len; j++) |
| 996 | { | 1040 | { |
| 997 | faces[j] = Fcar (prop); | 1041 | faces[j] = Fcar (prop); |
| 998 | prop = Fcdr (prop); | 1042 | prop = Fcdr (prop); |
| 999 | } | 1043 | } |
| 1000 | /* So that we can merge them in the reverse order */ | 1044 | /* So that we can merge them in the reverse order. */ |
| 1001 | for (j = len - 1; j >= 0; j--) | ||
| 1002 | { | ||
| 1003 | facecode = face_name_id_number (f, faces[j]); | ||
| 1004 | if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f) | ||
| 1005 | && FRAME_PARAM_FACES (f) [facecode] != 0) | ||
| 1006 | merge_faces (FRAME_PARAM_FACES (f) [facecode], &face); | ||
| 1007 | } | ||
| 1008 | } | 1045 | } |
| 1009 | else if (!NILP (prop)) | 1046 | else |
| 1010 | { | 1047 | { |
| 1011 | facecode = face_name_id_number (f, prop); | 1048 | faces = (Lisp_Object *) alloca (sizeof (Lisp_Object)); |
| 1012 | if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f) | 1049 | faces[0] = prop; |
| 1013 | && FRAME_PARAM_FACES (f) [facecode] != 0) | 1050 | len = 1; |
| 1014 | merge_faces (FRAME_PARAM_FACES (f) [facecode], &face); | ||
| 1015 | } | 1051 | } |
| 1016 | 1052 | ||
| 1017 | noverlays = sort_overlays (overlay_vec, noverlays, w); | 1053 | for (j = len - 1; j >= 0; j--) |
| 1018 | |||
| 1019 | /* Now merge the overlay data in that order. */ | ||
| 1020 | for (i = 0; i < noverlays; i++) | ||
| 1021 | { | 1054 | { |
| 1022 | prop = Foverlay_get (overlay_vec[i], propname); | 1055 | if (CONSP (faces[j])) |
| 1023 | if (CONSP (prop)) | ||
| 1024 | { | 1056 | { |
| 1025 | /* We have a list of faces, merge them in reverse order */ | 1057 | if (EQ (XCONS (faces[j])->car, Qbackground_color)) |
| 1026 | Lisp_Object length; | 1058 | face->background = load_color (f, XCONS (faces[j])->cdr); |
| 1027 | int len; | 1059 | if (EQ (XCONS (faces[j])->car, Qforeground_color)) |
| 1028 | Lisp_Object *faces; | 1060 | face->foreground = load_color (f, XCONS (faces[j])->cdr); |
| 1029 | |||
| 1030 | length = Fsafe_length (prop); | ||
| 1031 | len = XFASTINT (length); | ||
| 1032 | |||
| 1033 | /* Put them into an array */ | ||
| 1034 | faces = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); | ||
| 1035 | for (j = 0; j < len; j++) | ||
| 1036 | { | ||
| 1037 | faces[j] = Fcar (prop); | ||
| 1038 | prop = Fcdr (prop); | ||
| 1039 | } | ||
| 1040 | /* So that we can merge them in the reverse order */ | ||
| 1041 | for (j = len - 1; j >= 0; j--) | ||
| 1042 | { | ||
| 1043 | facecode = face_name_id_number (f, faces[j]); | ||
| 1044 | if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f) | ||
| 1045 | && FRAME_PARAM_FACES (f) [facecode] != 0) | ||
| 1046 | merge_faces (FRAME_PARAM_FACES (f) [facecode], &face); | ||
| 1047 | } | ||
| 1048 | } | 1061 | } |
| 1049 | else if (!NILP (prop)) | 1062 | else |
| 1050 | { | 1063 | { |
| 1051 | Lisp_Object oend; | 1064 | int facecode = face_name_id_number (f, faces[j]); |
| 1052 | int oendpos; | ||
| 1053 | |||
| 1054 | facecode = face_name_id_number (f, prop); | ||
| 1055 | if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f) | 1065 | if (facecode >= 0 && facecode < FRAME_N_PARAM_FACES (f) |
| 1056 | && FRAME_PARAM_FACES (f) [facecode] != 0) | 1066 | && FRAME_PARAM_FACES (f) [facecode] != 0) |
| 1057 | merge_faces (FRAME_PARAM_FACES (f)[facecode], &face); | 1067 | merge_faces (FRAME_PARAM_FACES (f) [facecode], face); |
| 1058 | |||
| 1059 | oend = OVERLAY_END (overlay_vec[i]); | ||
| 1060 | oendpos = OVERLAY_POSITION (oend); | ||
| 1061 | if (oendpos < endpos) | ||
| 1062 | endpos = oendpos; | ||
| 1063 | } | 1068 | } |
| 1064 | } | 1069 | } |
| 1065 | |||
| 1066 | if (pos >= region_beg && pos < region_end) | ||
| 1067 | { | ||
| 1068 | if (region_end < endpos) | ||
| 1069 | endpos = region_end; | ||
| 1070 | if (region_face >= 0 && region_face < next_face_id) | ||
| 1071 | merge_faces (FRAME_PARAM_FACES (f)[region_face], &face); | ||
| 1072 | } | ||
| 1073 | |||
| 1074 | *endptr = endpos; | ||
| 1075 | |||
| 1076 | return intern_computed_face (f, &face); | ||
| 1077 | } | 1070 | } |
| 1071 | |||
| 1078 | 1072 | ||
| 1079 | /* Recompute the GC's for the default and modeline faces. | 1073 | /* Recompute the GC's for the default and modeline faces. |
| 1080 | We call this after changing frame parameters on which those GC's | 1074 | We call this after changing frame parameters on which those GC's |