comparison src/xfaces.c @ 26902:264b83a3a688

Changes for separate unspecified foreground and background colors on character terminals: * dispextern.h (FACE_TTY_DEFAULT_FG_COLOR) (FACE_TTY_DEFAULT_BG_COLOR): New macros. * xfaces.c (Qunspecified_fg, Qunspecified_bg): New variables. (syms_of_xfaces): Initialize and staticpro them. (tty_defined_color): If the color name is unspecified-fg or unspecified-bg, return FACE_TTY_DEFAULT_FG_COLOR and FACE_TTY_DEFAULT_BG_COLOR, respectively, as the pixel value. (tty_color_name): If the color pixel value is either FACE_TTY_DEFAULT_FG_COLOR or FACE_TTY_DEFAULT_BG_COLOR, return Qunspecified_fg or Qunspecified_bg, respectively. (Finternal_set_lisp_face_attribute): Allow values Qunspecified_fg and Qunspecified_bg for foreground and background colors. (realize_default_face): If the foreground and background colors are not specified, default to Qunspecified_fg and Qunspecified_bg. (realize_tty_face): By default, set the face colors to FACE_TTY_DEFAULT_FG_COLOR and FACE_TTY_DEFAULT_BG_COLOR. [MSDOS]: Handle FACE_TTY_DEFAULT_FG_COLOR and FACE_TTY_DEFAULT_BG_COLOR when face colors are not defined. Reverse the colors if the default colors were reversed. * dispnew.c (init_display): Initialize the frame pixels of the initial frame to FACE_TTY_DEFAULT_FG_COLOR and FACE_TTY_DEFAULT_BG_COLOR. * term.c (turn_on_face): If the default fore- and background colors are reversed, enter inverse video mode. Don't send color escape sequences for unspecified foreground and background colors. (turn_off_face): Handle unspecified-fg and unspecified-bg colors. * dosfns.c (unspecified_colors): New variable. (msdos_stdcolor_idx): Handle unspecified-fg and unspecified-bg color names, return FACE_TTY_DEFAULT_FG_COLOR and FACE_TTY_DEFAULT_BG_COLOR, respectively. (msdos_stdcolor_name): Handle FACE_TTY_DEFAULT_FG_COLOR and FACE_TTY_DEFAULT_BG_COLOR, return Qunspecified_fg and Qunspecified_bg, respectively. * msdos.c (IT_set_face): Support FACE_TTY_DEFAULT_FG_COLOR and FACE_TTY_DEFAULT_BG_COLOR as pixel values. * faces.el (face-read-integer, read-face-attribute) (color-defined-p, color-values): Allow color values unspecified-fg and unspecified-bg, handle them as unspecified.
author Eli Zaretskii <eliz@gnu.org>
date Wed, 15 Dec 1999 13:14:38 +0000
parents d6aa11f2a4af
children 9d6d94db8909
comparison
equal deleted inserted replaced
26901:cfaf05bc5ac2 26902:264b83a3a688
280 Lisp_Object Qultra_condensed, Qextra_condensed, Qcondensed; 280 Lisp_Object Qultra_condensed, Qextra_condensed, Qcondensed;
281 Lisp_Object Qsemi_condensed, Qsemi_expanded, Qexpanded, Qextra_expanded; 281 Lisp_Object Qsemi_condensed, Qsemi_expanded, Qexpanded, Qextra_expanded;
282 Lisp_Object Qultra_expanded; 282 Lisp_Object Qultra_expanded;
283 Lisp_Object Qreleased_button, Qpressed_button; 283 Lisp_Object Qreleased_button, Qpressed_button;
284 Lisp_Object QCstyle, QCcolor, QCline_width; 284 Lisp_Object QCstyle, QCcolor, QCline_width;
285 Lisp_Object Qunspecified; 285 Lisp_Object Qunspecified, Qunspecified_fg, Qunspecified_bg;
286 286
287 /* The symbol `x-charset-registry'. This property of charsets defines 287 /* The symbol `x-charset-registry'. This property of charsets defines
288 the X registry and encoding that fonts should have that are used to 288 the X registry and encoding that fonts should have that are used to
289 display characters of that charset. */ 289 display characters of that charset. */
290 290
1106 yet set up in tty-color-alist. Don't return a failure 1106 yet set up in tty-color-alist. Don't return a failure
1107 indication, since this produces the annoying "Unable to 1107 indication, since this produces the annoying "Unable to
1108 load color" messages in the *Messages* buffer. */ 1108 load color" messages in the *Messages* buffer. */
1109 status = 1; 1109 status = 1;
1110 } 1110 }
1111 if (color_idx == FACE_TTY_DEFAULT_COLOR && *color_name)
1112 {
1113 if (strcmp (color_name, "unspecified-fg") == 0)
1114 color_idx = FACE_TTY_DEFAULT_FG_COLOR;
1115 else if (strcmp (color_name, "unspecified-bg") == 0)
1116 color_idx = FACE_TTY_DEFAULT_BG_COLOR;
1117 }
1118
1111 color_def->pixel = (unsigned long) color_idx; 1119 color_def->pixel = (unsigned long) color_idx;
1112 color_def->red = red; 1120 color_def->red = red;
1113 color_def->green = green; 1121 color_def->green = green;
1114 color_def->blue = blue; 1122 color_def->blue = blue;
1115 1123
1177 /* FIXME: When/if w32 supports colors in non-window mode, there should 1185 /* FIXME: When/if w32 supports colors in non-window mode, there should
1178 be a call here to a w32-specific function that returns the color 1186 be a call here to a w32-specific function that returns the color
1179 by index using the default color mapping on a Windows console. */ 1187 by index using the default color mapping on a Windows console. */
1180 #endif 1188 #endif
1181 1189
1182 return Qunspecified; 1190 return
1191 idx == FACE_TTY_DEFAULT_FG_COLOR ? Qunspecified_fg
1192 : idx == FACE_TTY_DEFAULT_BG_COLOR ? Qunspecified_bg
1193 : Qunspecified;
1183 } 1194 }
1184 1195
1185 /* Return non-zero if COLOR_NAME is a shade of gray (or white or 1196 /* Return non-zero if COLOR_NAME is a shade of gray (or white or
1186 black) on frame F. The algorithm is taken from 20.2 faces.el. */ 1197 black) on frame F. The algorithm is taken from 20.2 faces.el. */
1187 1198
3425 old_value = LFACE_INVERSE (lface); 3436 old_value = LFACE_INVERSE (lface);
3426 LFACE_INVERSE (lface) = value; 3437 LFACE_INVERSE (lface) = value;
3427 } 3438 }
3428 else if (EQ (attr, QCforeground)) 3439 else if (EQ (attr, QCforeground))
3429 { 3440 {
3430 if (!UNSPECIFIEDP (value)) 3441 if (!UNSPECIFIEDP (value)
3442 && !EQ (value, Qunspecified_fg) && !EQ (value, Qunspecified_bg))
3431 { 3443 {
3432 /* Don't check for valid color names here because it depends 3444 /* Don't check for valid color names here because it depends
3433 on the frame (display) whether the color will be valid 3445 on the frame (display) whether the color will be valid
3434 when the face is realized. */ 3446 when the face is realized. */
3435 CHECK_STRING (value, 3); 3447 CHECK_STRING (value, 3);
3439 old_value = LFACE_FOREGROUND (lface); 3451 old_value = LFACE_FOREGROUND (lface);
3440 LFACE_FOREGROUND (lface) = value; 3452 LFACE_FOREGROUND (lface) = value;
3441 } 3453 }
3442 else if (EQ (attr, QCbackground)) 3454 else if (EQ (attr, QCbackground))
3443 { 3455 {
3444 if (!UNSPECIFIEDP (value)) 3456 if (!UNSPECIFIEDP (value)
3457 && !EQ (value, Qunspecified_bg) && !EQ (value, Qunspecified_fg))
3445 { 3458 {
3446 /* Don't check for valid color names here because it depends 3459 /* Don't check for valid color names here because it depends
3447 on the frame (display) whether the color will be valid 3460 on the frame (display) whether the color will be valid
3448 when the face is realized. */ 3461 when the face is realized. */
3449 CHECK_STRING (value, 3); 3462 CHECK_STRING (value, 3);
5684 5697
5685 if (CONSP (color) && STRINGP (XCDR (color))) 5698 if (CONSP (color) && STRINGP (XCDR (color)))
5686 LFACE_FOREGROUND (lface) = XCDR (color); 5699 LFACE_FOREGROUND (lface) = XCDR (color);
5687 else if (FRAME_X_P (f)) 5700 else if (FRAME_X_P (f))
5688 return 0; 5701 return 0;
5689 else if (!FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f)) 5702 else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
5703 LFACE_FOREGROUND (lface) = Qunspecified_fg;
5704 else
5690 abort (); 5705 abort ();
5691 } 5706 }
5692 5707
5693 if (UNSPECIFIEDP (LFACE_BACKGROUND (lface))) 5708 if (UNSPECIFIEDP (LFACE_BACKGROUND (lface)))
5694 { 5709 {
5697 Lisp_Object color = Fassq (Qbackground_color, f->param_alist); 5712 Lisp_Object color = Fassq (Qbackground_color, f->param_alist);
5698 if (CONSP (color) && STRINGP (XCDR (color))) 5713 if (CONSP (color) && STRINGP (XCDR (color)))
5699 LFACE_BACKGROUND (lface) = XCDR (color); 5714 LFACE_BACKGROUND (lface) = XCDR (color);
5700 else if (FRAME_X_P (f)) 5715 else if (FRAME_X_P (f))
5701 return 0; 5716 return 0;
5702 else if (!FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f)) 5717 else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
5718 LFACE_BACKGROUND (lface) = Qunspecified_bg;
5719 else
5703 abort (); 5720 abort ();
5704 } 5721 }
5705 5722
5706 if (UNSPECIFIEDP (LFACE_STIPPLE (lface))) 5723 if (UNSPECIFIEDP (LFACE_STIPPLE (lface)))
5707 LFACE_STIPPLE (lface) = Qnil; 5724 LFACE_STIPPLE (lface) = Qnil;
6070 face->tty_underline_p = 1; 6087 face->tty_underline_p = 1;
6071 if (!NILP (attrs[LFACE_INVERSE_INDEX])) 6088 if (!NILP (attrs[LFACE_INVERSE_INDEX]))
6072 face->tty_reverse_p = 1; 6089 face->tty_reverse_p = 1;
6073 6090
6074 /* Map color names to color indices. */ 6091 /* Map color names to color indices. */
6075 face->foreground = face->background = FACE_TTY_DEFAULT_COLOR; 6092 face->foreground = FACE_TTY_DEFAULT_FG_COLOR;
6093 face->background = FACE_TTY_DEFAULT_BG_COLOR;
6076 6094
6077 color = attrs[LFACE_FOREGROUND_INDEX]; 6095 color = attrs[LFACE_FOREGROUND_INDEX];
6078 if (STRINGP (color) 6096 if (STRINGP (color)
6079 && XSTRING (color)->size 6097 && XSTRING (color)->size
6080 && !NILP (tty_color_alist) 6098 && !NILP (tty_color_alist)
6082 CONSP (color))) 6100 CONSP (color)))
6083 /* Associations in tty-color-alist are of the form 6101 /* Associations in tty-color-alist are of the form
6084 (NAME INDEX R G B). We need the INDEX part. */ 6102 (NAME INDEX R G B). We need the INDEX part. */
6085 face->foreground = XINT (XCAR (XCDR (color))); 6103 face->foreground = XINT (XCAR (XCDR (color)));
6086 6104
6087 if (face->foreground == FACE_TTY_DEFAULT_COLOR 6105 if (face->foreground == FACE_TTY_DEFAULT_FG_COLOR
6088 && STRINGP (attrs[LFACE_FOREGROUND_INDEX])) 6106 && STRINGP (attrs[LFACE_FOREGROUND_INDEX]))
6089 { 6107 {
6090 face->foreground = load_color (c->f, face, 6108 face->foreground = load_color (c->f, face,
6091 attrs[LFACE_FOREGROUND_INDEX], 6109 attrs[LFACE_FOREGROUND_INDEX],
6092 LFACE_FOREGROUND_INDEX); 6110 LFACE_FOREGROUND_INDEX);
6093 #ifdef MSDOS 6111 #ifdef MSDOS
6094 /* If the foreground of the default face is the default color, 6112 /* If the foreground of the default face is the default color,
6095 use the foreground color defined by the frame. */ 6113 use the foreground color defined by the frame. */
6096 if (FRAME_MSDOS_P (c->f) && face->foreground == FACE_TTY_DEFAULT_COLOR) 6114 if (FRAME_MSDOS_P (c->f))
6097 { 6115 {
6098 face->foreground = FRAME_FOREGROUND_PIXEL (f); 6116 if (face->foreground == FACE_TTY_DEFAULT_FG_COLOR
6099 attrs[LFACE_FOREGROUND_INDEX] = 6117 || face->foreground == FACE_TTY_DEFAULT_COLOR)
6100 msdos_stdcolor_name (face->foreground); 6118 {
6101 face_colors_defaulted = 1; 6119 face->foreground = FRAME_FOREGROUND_PIXEL (f);
6120 attrs[LFACE_FOREGROUND_INDEX] =
6121 msdos_stdcolor_name (face->foreground);
6122 face_colors_defaulted = 1;
6123 }
6124 else if (face->foreground == FACE_TTY_DEFAULT_BG_COLOR)
6125 {
6126 face->foreground = FRAME_BACKGROUND_PIXEL (f);
6127 attrs[LFACE_FOREGROUND_INDEX] =
6128 msdos_stdcolor_name (face->foreground);
6129 face_colors_defaulted = 1;
6130 }
6102 } 6131 }
6103 #endif 6132 #endif
6104 } 6133 }
6105 6134
6106 color = attrs[LFACE_BACKGROUND_INDEX]; 6135 color = attrs[LFACE_BACKGROUND_INDEX];
6111 CONSP (color))) 6140 CONSP (color)))
6112 /* Associations in tty-color-alist are of the form 6141 /* Associations in tty-color-alist are of the form
6113 (NAME INDEX R G B). We need the INDEX part. */ 6142 (NAME INDEX R G B). We need the INDEX part. */
6114 face->background = XINT (XCAR (XCDR (color))); 6143 face->background = XINT (XCAR (XCDR (color)));
6115 6144
6116 if (face->background == FACE_TTY_DEFAULT_COLOR 6145 if (face->background == FACE_TTY_DEFAULT_BG_COLOR
6117 && STRINGP (attrs[LFACE_BACKGROUND_INDEX])) 6146 && STRINGP (attrs[LFACE_BACKGROUND_INDEX]))
6118 { 6147 {
6119 face->background = load_color (c->f, face, 6148 face->background = load_color (c->f, face,
6120 attrs[LFACE_BACKGROUND_INDEX], 6149 attrs[LFACE_BACKGROUND_INDEX],
6121 LFACE_BACKGROUND_INDEX); 6150 LFACE_BACKGROUND_INDEX);
6122 #ifdef MSDOS 6151 #ifdef MSDOS
6123 /* If the background of the default face is the default color, 6152 /* If the background of the default face is the default color,
6124 use the background color defined by the frame. */ 6153 use the background color defined by the frame. */
6125 if (FRAME_MSDOS_P (c->f) && face->background == FACE_TTY_DEFAULT_COLOR) 6154 if (FRAME_MSDOS_P (c->f))
6126 { 6155 {
6127 face->background = FRAME_BACKGROUND_PIXEL (f); 6156 if (face->background == FACE_TTY_DEFAULT_BG_COLOR
6128 attrs[LFACE_BACKGROUND_INDEX] = 6157 || face->background == FACE_TTY_DEFAULT_COLOR)
6129 msdos_stdcolor_name (face->background); 6158 {
6130 face_colors_defaulted = 1; 6159 face->background = FRAME_BACKGROUND_PIXEL (f);
6160 attrs[LFACE_BACKGROUND_INDEX] =
6161 msdos_stdcolor_name (face->background);
6162 face_colors_defaulted = 1;
6163 }
6164 else if (face->background == FACE_TTY_DEFAULT_FG_COLOR)
6165 {
6166 face->background = FRAME_FOREGROUND_PIXEL (f);
6167 attrs[LFACE_BACKGROUND_INDEX] =
6168 msdos_stdcolor_name (face->background);
6169 face_colors_defaulted = 1;
6170 }
6131 } 6171 }
6132 #endif 6172 #endif
6133 } 6173 }
6134 6174
6135 /* Swap colors if face is inverse-video. If the colors are taken 6175 /* Swap colors if face is inverse-video. If the colors are taken
6609 staticpro (&Qbackground_color); 6649 staticpro (&Qbackground_color);
6610 Qforeground_color = intern ("foreground-color"); 6650 Qforeground_color = intern ("foreground-color");
6611 staticpro (&Qforeground_color); 6651 staticpro (&Qforeground_color);
6612 Qunspecified = intern ("unspecified"); 6652 Qunspecified = intern ("unspecified");
6613 staticpro (&Qunspecified); 6653 staticpro (&Qunspecified);
6654 Qunspecified_fg = intern ("unspecified-fg");
6655 staticpro (&Qunspecified_fg);
6656 Qunspecified_bg = intern ("unspecified-bg");
6657 staticpro (&Qunspecified_bg);
6614 6658
6615 Qx_charset_registry = intern ("x-charset-registry"); 6659 Qx_charset_registry = intern ("x-charset-registry");
6616 staticpro (&Qx_charset_registry); 6660 staticpro (&Qx_charset_registry);
6617 Qface_alias = intern ("face-alias"); 6661 Qface_alias = intern ("face-alias");
6618 staticpro (&Qface_alias); 6662 staticpro (&Qface_alias);