aboutsummaryrefslogtreecommitdiffstats
path: root/src/xfaces.c
diff options
context:
space:
mode:
authorEli Zaretskii1999-12-15 13:14:38 +0000
committerEli Zaretskii1999-12-15 13:14:38 +0000
commitf9d2fdc464f130fbde700cecc00c031ef7e8e4f2 (patch)
tree2102159b730a603bb26d4e7d5162211d958058d7 /src/xfaces.c
parente19539f184768f9411860daf9ef9d983e48e2650 (diff)
downloademacs-f9d2fdc464f130fbde700cecc00c031ef7e8e4f2.tar.gz
emacs-f9d2fdc464f130fbde700cecc00c031ef7e8e4f2.zip
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.
Diffstat (limited to 'src/xfaces.c')
-rw-r--r--src/xfaces.c82
1 files changed, 63 insertions, 19 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 5fdb881bfc0..dd51df034ac 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -282,7 +282,7 @@ Lisp_Object Qsemi_condensed, Qsemi_expanded, Qexpanded, Qextra_expanded;
282Lisp_Object Qultra_expanded; 282Lisp_Object Qultra_expanded;
283Lisp_Object Qreleased_button, Qpressed_button; 283Lisp_Object Qreleased_button, Qpressed_button;
284Lisp_Object QCstyle, QCcolor, QCline_width; 284Lisp_Object QCstyle, QCcolor, QCline_width;
285Lisp_Object Qunspecified; 285Lisp_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
@@ -1108,6 +1108,14 @@ tty_defined_color (f, color_name, color_def, alloc)
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;
@@ -1179,7 +1187,10 @@ tty_color_name (f, idx)
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
@@ -3427,7 +3438,8 @@ frame.")
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
@@ -3441,7 +3453,8 @@ frame.")
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
@@ -5686,7 +5699,9 @@ realize_default_face (f)
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
@@ -5699,7 +5714,9 @@ realize_default_face (f)
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
@@ -6072,7 +6089,8 @@ realize_tty_face (c, attrs, charset)
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)
@@ -6084,7 +6102,7 @@ realize_tty_face (c, attrs, charset)
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,
@@ -6093,12 +6111,23 @@ realize_tty_face (c, attrs, charset)
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 }
@@ -6113,7 +6142,7 @@ realize_tty_face (c, attrs, charset)
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,
@@ -6122,12 +6151,23 @@ realize_tty_face (c, attrs, charset)
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 }
@@ -6611,6 +6651,10 @@ syms_of_xfaces ()
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);