aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2000-08-20 13:23:01 +0000
committerGerd Moellmann2000-08-20 13:23:01 +0000
commitae4b4ba5df169afbd7878e7c1092ecf3ff7cd61f (patch)
tree41ce06c0beecebece8507ec4f3d96f00ffc63319 /src
parenta9de7d29be745a0f5309833a4b6ead2391fd9de7 (diff)
downloademacs-ae4b4ba5df169afbd7878e7c1092ecf3ff7cd61f.tar.gz
emacs-ae4b4ba5df169afbd7878e7c1092ecf3ff7cd61f.zip
(lface_equal_p): Compare strings differently.
(Qtty_color_alist, Vtty_defined_color_alist): New variables. (realize_tty_face): Use them. (syms_of_xfaces): Initialize new variables. (map_tty_color): New function, extracted from realize_tty_face. (map_tty_color) [MSDOS || WINDOWSNT]: If using the frame's default foreground or background color, store the new color name in the realized face; previous code trying to do this had no effect. (realize_tty_face): Use map_tty_color. (Fclear_face_cache): Set face_change_count and ensure thorough redisplay.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c232
1 files changed, 123 insertions, 109 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index e7b1e2c5354..76e546bd00c 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -283,14 +283,19 @@ Boston, MA 02111-1307, USA. */
283#define FACE_CACHE_BUCKETS_SIZE 1001 283#define FACE_CACHE_BUCKETS_SIZE 1001
284 284
285/* A definition of XColor for non-X frames. */ 285/* A definition of XColor for non-X frames. */
286
286#ifndef HAVE_X_WINDOWS 287#ifndef HAVE_X_WINDOWS
287typedef struct { 288
289typedef struct
290{
288 unsigned long pixel; 291 unsigned long pixel;
289 unsigned short red, green, blue; 292 unsigned short red, green, blue;
290 char flags; 293 char flags;
291 char pad; 294 char pad;
292} XColor; 295}
293#endif 296XColor;
297
298#endif /* not HAVE_X_WINDOWS */
294 299
295/* Keyword symbols used for face attribute names. */ 300/* Keyword symbols used for face attribute names. */
296 301
@@ -396,9 +401,18 @@ static int next_lface_id;
396static Lisp_Object *lface_id_to_name; 401static Lisp_Object *lface_id_to_name;
397static int lface_id_to_name_size; 402static int lface_id_to_name_size;
398 403
399/* tty color-related functions (defined on lisp/term/tty-colors.el). */ 404/* TTY color-related functions (defined in tty-colors.el). */
405
400Lisp_Object Qtty_color_desc, Qtty_color_by_index; 406Lisp_Object Qtty_color_desc, Qtty_color_by_index;
401 407
408/* The name of the function used to compute colors on TTYs. */
409
410Lisp_Object Qtty_color_alist;
411
412/* An alist of defined terminal colors and their RGB values. */
413
414Lisp_Object Vtty_defined_color_alist;
415
402/* Counter for calls to clear_face_cache. If this counter reaches 416/* Counter for calls to clear_face_cache. If this counter reaches
403 CLEAR_FONT_TABLE_COUNT, and a frame has more than 417 CLEAR_FONT_TABLE_COUNT, and a frame has more than
404 CLEAR_FONT_TABLE_NFONTS load, unused fonts are freed. */ 418 CLEAR_FONT_TABLE_NFONTS load, unused fonts are freed. */
@@ -434,6 +448,8 @@ static int ngcs;
434struct font_name; 448struct font_name;
435struct table_entry; 449struct table_entry;
436 450
451static void map_tty_color P_ ((struct frame *, struct face *,
452 enum lface_attribute_index, int *));
437static Lisp_Object resolve_face_name P_ ((Lisp_Object)); 453static Lisp_Object resolve_face_name P_ ((Lisp_Object));
438static int may_use_scalable_font_p P_ ((struct font_name *, char *)); 454static int may_use_scalable_font_p P_ ((struct font_name *, char *));
439static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object)); 455static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object));
@@ -939,6 +955,8 @@ Optional THOROUGHLY non-nil means try to free unused fonts, too.")
939 Lisp_Object thorougly; 955 Lisp_Object thorougly;
940{ 956{
941 clear_face_cache (!NILP (thorougly)); 957 clear_face_cache (!NILP (thorougly));
958 ++face_change_count;
959 ++windows_or_buffers_changed;
942 return Qnil; 960 return Qnil;
943} 961}
944 962
@@ -1213,8 +1231,8 @@ tty_defined_color (f, color_name, color_def, alloc)
1213 int alloc; 1231 int alloc;
1214{ 1232{
1215 Lisp_Object color_desc; 1233 Lisp_Object color_desc;
1216 unsigned long color_idx = FACE_TTY_DEFAULT_COLOR, 1234 unsigned long color_idx = FACE_TTY_DEFAULT_COLOR;
1217 red = 0, green = 0, blue = 0; 1235 unsigned long red = 0, green = 0, blue = 0;
1218 int status = 1; 1236 int status = 1;
1219 1237
1220 if (*color_name && !NILP (Ffboundp (Qtty_color_desc))) 1238 if (*color_name && !NILP (Ffboundp (Qtty_color_desc)))
@@ -4372,9 +4390,10 @@ lface_equal_p (v1, v2)
4372 switch (XTYPE (a)) 4390 switch (XTYPE (a))
4373 { 4391 {
4374 case Lisp_String: 4392 case Lisp_String:
4375 equal_p = (XSTRING (a)->size == XSTRING (b)->size 4393 equal_p = ((STRING_BYTES (XSTRING (a))
4394 == STRING_BYTES (XSTRING (b)))
4376 && bcmp (XSTRING (a)->data, XSTRING (b)->data, 4395 && bcmp (XSTRING (a)->data, XSTRING (b)->data,
4377 XSTRING (a)->size) == 0); 4396 STRING_BYTES (XSTRING (a))) == 0);
4378 break; 4397 break;
4379 4398
4380 case Lisp_Int: 4399 case Lisp_Int:
@@ -6073,6 +6092,92 @@ realize_x_face (cache, attrs, c, base_face)
6073} 6092}
6074 6093
6075 6094
6095/* Map a specified color of face FACE on frame F to a tty color index.
6096 IDX is either LFACE_FOREGROUND_INDEX or LFACE_BACKGROUND_INDEX, and
6097 specifies which color to map. Set *DEFAULTED to 1 if mapping to the
6098 default foreground/background colors. */
6099
6100static void
6101map_tty_color (f, face, idx, defaulted)
6102 struct frame *f;
6103 struct face *face;
6104 enum lface_attribute_index idx;
6105 int *defaulted;
6106{
6107 Lisp_Object frame, color, def;
6108 int foreground_p = idx == LFACE_FOREGROUND_INDEX;
6109 unsigned long default_pixel, default_other_pixel, pixel;
6110
6111 xassert (idx == LFACE_FOREGROUND_INDEX || idx == LFACE_BACKGROUND_INDEX);
6112
6113 if (foreground_p)
6114 {
6115 pixel = default_pixel = FACE_TTY_DEFAULT_FG_COLOR;
6116 default_other_pixel = FACE_TTY_DEFAULT_BG_COLOR;
6117 }
6118 else
6119 {
6120 pixel = default_pixel = FACE_TTY_DEFAULT_BG_COLOR;
6121 default_other_pixel = FACE_TTY_DEFAULT_FG_COLOR;
6122 }
6123
6124 XSETFRAME (frame, f);
6125 color = face->lface[idx];
6126
6127 if (STRINGP (color)
6128 && XSTRING (color)->size
6129 && CONSP (Vtty_defined_color_alist)
6130 && (def = assq_no_quit (color, call1 (Qtty_color_alist, frame)),
6131 CONSP (def)))
6132 {
6133 /* Associations in tty-defined-color-alist are of the form
6134 (NAME INDEX R G B). We need the INDEX part. */
6135 pixel = XINT (XCAR (XCDR (def)));
6136 }
6137
6138 if (pixel == default_pixel && STRINGP (color))
6139 {
6140 pixel = load_color (f, face, color, idx);
6141
6142#if defined (MSDOS) || defined (WINDOWSNT)
6143 /* If the foreground of the default face is the default color,
6144 use the foreground color defined by the frame. */
6145#ifdef MSDOS
6146 if (FRAME_MSDOS_P (f))
6147 {
6148#endif /* MSDOS */
6149 if (pixel == default_pixel
6150 || pixel == FACE_TTY_DEFAULT_COLOR)
6151 {
6152 if (foreground_p)
6153 pixel = FRAME_FOREGROUND_PIXEL (f);
6154 else
6155 pixel = FRAME_BACKGROUND_PIXEL (f);
6156 face->lface[idx] = tty_color_name (f, pixel);
6157 *defaulted = 1;
6158 }
6159 else if (pixel == default_other_pixel)
6160 {
6161 if (foreground_p)
6162 pixel = FRAME_BACKGROUND_PIXEL (f);
6163 else
6164 pixel = FRAME_FOREGROUND_PIXEL (f);
6165 face->lface[idx] = tty_color_name (f, pixel);
6166 *defaulted = 1;
6167 }
6168#ifdef MSDOS
6169 }
6170#endif
6171#endif /* MSDOS or WINDOWSNT */
6172 }
6173
6174 if (foreground_p)
6175 face->foreground = pixel;
6176 else
6177 face->background = pixel;
6178}
6179
6180
6076/* Realize the fully-specified face with attributes ATTRS in face 6181/* Realize the fully-specified face with attributes ATTRS in face
6077 cache CACHE for character C. Do it for TTY frame CACHE->f. Value is a 6182 cache CACHE for character C. Do it for TTY frame CACHE->f. Value is a
6078 pointer to the newly created realized face. */ 6183 pointer to the newly created realized face. */
@@ -6085,12 +6190,8 @@ realize_tty_face (cache, attrs, c)
6085{ 6190{
6086 struct face *face; 6191 struct face *face;
6087 int weight, slant; 6192 int weight, slant;
6088 Lisp_Object color;
6089 Lisp_Object tty_defined_color_alist
6090 = find_symbol_value (intern ("tty-defined-color-alist"));
6091 Lisp_Object tty_color_alist = intern ("tty-color-alist");
6092 Lisp_Object frame;
6093 int face_colors_defaulted = 0; 6193 int face_colors_defaulted = 0;
6194 struct frame *f = cache->f;
6094 6195
6095 /* Frame must be a termcap frame. */ 6196 /* Frame must be a termcap frame. */
6096 xassert (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f)); 6197 xassert (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f));
@@ -6115,108 +6216,15 @@ realize_tty_face (cache, attrs, c)
6115 face->tty_reverse_p = 1; 6216 face->tty_reverse_p = 1;
6116 6217
6117 /* Map color names to color indices. */ 6218 /* Map color names to color indices. */
6118 face->foreground = FACE_TTY_DEFAULT_FG_COLOR; 6219 map_tty_color (f, face, LFACE_FOREGROUND_INDEX, &face_colors_defaulted);
6119 face->background = FACE_TTY_DEFAULT_BG_COLOR; 6220 map_tty_color (f, face, LFACE_BACKGROUND_INDEX, &face_colors_defaulted);
6120 6221
6121 XSETFRAME (frame, cache->f);
6122 color = attrs[LFACE_FOREGROUND_INDEX];
6123 if (STRINGP (color)
6124 && XSTRING (color)->size
6125 && CONSP (tty_defined_color_alist)
6126 && (color = Fassoc (color, call1 (tty_color_alist, frame)),
6127 CONSP (color)))
6128 /* Associations in tty-defined-color-alist are of the form
6129 (NAME INDEX R G B). We need the INDEX part. */
6130 face->foreground = XINT (XCAR (XCDR (color)));
6131
6132 if (face->foreground == FACE_TTY_DEFAULT_FG_COLOR
6133 && STRINGP (attrs[LFACE_FOREGROUND_INDEX]))
6134 {
6135 face->foreground = load_color (cache->f, face,
6136 attrs[LFACE_FOREGROUND_INDEX],
6137 LFACE_FOREGROUND_INDEX);
6138
6139#if defined (MSDOS) || defined (WINDOWSNT)
6140 /* If the foreground of the default face is the default color,
6141 use the foreground color defined by the frame. */
6142#ifdef MSDOS
6143 if (FRAME_MSDOS_P (cache->f))
6144 {
6145#endif /* MSDOS */
6146
6147 if (face->foreground == FACE_TTY_DEFAULT_FG_COLOR
6148 || face->foreground == FACE_TTY_DEFAULT_COLOR)
6149 {
6150 face->foreground = FRAME_FOREGROUND_PIXEL (cache->f);
6151 attrs[LFACE_FOREGROUND_INDEX] =
6152 tty_color_name (cache->f, face->foreground);
6153 face_colors_defaulted = 1;
6154 }
6155 else if (face->foreground == FACE_TTY_DEFAULT_BG_COLOR)
6156 {
6157 face->foreground = FRAME_BACKGROUND_PIXEL (cache->f);
6158 attrs[LFACE_FOREGROUND_INDEX] =
6159 tty_color_name (cache->f, face->foreground);
6160 face_colors_defaulted = 1;
6161 }
6162#ifdef MSDOS
6163 }
6164#endif
6165#endif /* MSDOS or WINDOWSNT */
6166 }
6167
6168 color = attrs[LFACE_BACKGROUND_INDEX];
6169 if (STRINGP (color)
6170 && XSTRING (color)->size
6171 && CONSP (tty_defined_color_alist)
6172 && (color = Fassoc (color, call1 (tty_color_alist, frame)),
6173 CONSP (color)))
6174 /* Associations in tty-defined-color-alist are of the form
6175 (NAME INDEX R G B). We need the INDEX part. */
6176 face->background = XINT (XCAR (XCDR (color)));
6177
6178 if (face->background == FACE_TTY_DEFAULT_BG_COLOR
6179 && STRINGP (attrs[LFACE_BACKGROUND_INDEX]))
6180 {
6181 face->background = load_color (cache->f, face,
6182 attrs[LFACE_BACKGROUND_INDEX],
6183 LFACE_BACKGROUND_INDEX);
6184#if defined (MSDOS) || defined (WINDOWSNT)
6185 /* If the background of the default face is the default color,
6186 use the background color defined by the frame. */
6187#ifdef MSDOS
6188 if (FRAME_MSDOS_P (cache->f))
6189 {
6190#endif /* MSDOS */
6191
6192 if (face->background == FACE_TTY_DEFAULT_BG_COLOR
6193 || face->background == FACE_TTY_DEFAULT_COLOR)
6194 {
6195 face->background = FRAME_BACKGROUND_PIXEL (cache->f);
6196 attrs[LFACE_BACKGROUND_INDEX] =
6197 tty_color_name (cache->f, face->background);
6198 face_colors_defaulted = 1;
6199 }
6200 else if (face->background == FACE_TTY_DEFAULT_FG_COLOR)
6201 {
6202 face->background = FRAME_FOREGROUND_PIXEL (cache->f);
6203 attrs[LFACE_BACKGROUND_INDEX] =
6204 tty_color_name (cache->f, face->background);
6205 face_colors_defaulted = 1;
6206 }
6207#ifdef MSDOS
6208 }
6209#endif
6210#endif /* MSDOS or WINDOWSNT */
6211 }
6212
6213 /* Swap colors if face is inverse-video. If the colors are taken 6222 /* Swap colors if face is inverse-video. If the colors are taken
6214 from the frame colors, they are already inverted, since the 6223 from the frame colors, they are already inverted, since the
6215 frame-creation function calls x-handle-reverse-video. */ 6224 frame-creation function calls x-handle-reverse-video. */
6216 if (face->tty_reverse_p && !face_colors_defaulted) 6225 if (face->tty_reverse_p && !face_colors_defaulted)
6217 { 6226 {
6218 unsigned long tem = face->foreground; 6227 unsigned long tem = face->foreground;
6219
6220 face->foreground = face->background; 6228 face->foreground = face->background;
6221 face->background = tem; 6229 face->background = tem;
6222 } 6230 }
@@ -6737,6 +6745,8 @@ syms_of_xfaces ()
6737 staticpro (&Qtty_color_desc); 6745 staticpro (&Qtty_color_desc);
6738 Qtty_color_by_index = intern ("tty-color-by-index"); 6746 Qtty_color_by_index = intern ("tty-color-by-index");
6739 staticpro (&Qtty_color_by_index); 6747 staticpro (&Qtty_color_by_index);
6748 Qtty_color_alist = intern ("tty-color-alist");
6749 staticpro (&Qtty_color_alist);
6740 6750
6741 Vface_alternative_font_family_alist = Qnil; 6751 Vface_alternative_font_family_alist = Qnil;
6742 staticpro (&Vface_alternative_font_family_alist); 6752 staticpro (&Vface_alternative_font_family_alist);
@@ -6787,6 +6797,10 @@ instead of shades of gray for a face background color.\n\
6787See `set-face-stipple' for possible values for this variable."); 6797See `set-face-stipple' for possible values for this variable.");
6788 Vface_default_stipple = build_string ("gray3"); 6798 Vface_default_stipple = build_string ("gray3");
6789 6799
6800 DEFVAR_LISP ("tty-defined-color-alist", &Vtty_defined_color_alist,
6801 "An alist of defined terminal colors and their RGB values.");
6802 Vtty_defined_color_alist = Qnil;
6803
6790#if SCALABLE_FONTS 6804#if SCALABLE_FONTS
6791 6805
6792 DEFVAR_LISP ("scalable-fonts-allowed", &Vscalable_fonts_allowed, 6806 DEFVAR_LISP ("scalable-fonts-allowed", &Vscalable_fonts_allowed,