aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii1999-07-30 08:19:22 +0000
committerEli Zaretskii1999-07-30 08:19:22 +0000
commit44747bd00a9ad0b01f776f5dcd0ed0810112d771 (patch)
treee680677722da3e2e95a0a83d058e9b8983b29173
parente4441df01c386c7ce3e4092c9acd71c61b79862e (diff)
downloademacs-44747bd00a9ad0b01f776f5dcd0ed0810112d771.tar.gz
emacs-44747bd00a9ad0b01f776f5dcd0ed0810112d771.zip
(load_color): Remove static from definition and remove
prototype. [MSDOS]: Add a DOS-specific version of load_color. (lookup_face): Replace FRAME_TERMCAP_P with !FRAME_WINDOW_P. (lookup_derived_face): New function. (realize_default_face): Support MSDOS frames. [MSDOS]: If fore/background colors are unspecified, inherit them from the frame. (realize_face): Support MSDOS frames. (realize_tty_face): Support MSDOS frames. [MSDOS]: If the face color is not in Vface_tty_color_alist, call load_color to try to find a suitable approximation. If the face is inverse-video, swap the foreground and background colors.
-rw-r--r--src/xfaces.c152
1 files changed, 139 insertions, 13 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 6454a9a68af..6b2f759175d 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -393,10 +393,6 @@ static void signal_error P_ ((char *, Lisp_Object));
393static void display_message P_ ((struct frame *, char *, Lisp_Object, Lisp_Object)); 393static void display_message P_ ((struct frame *, char *, Lisp_Object, Lisp_Object));
394static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int)); 394static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int));
395static void load_face_font_or_fontset P_ ((struct frame *, struct face *, char *, int)); 395static void load_face_font_or_fontset P_ ((struct frame *, struct face *, char *, int));
396static unsigned long load_color P_ ((struct frame *,
397 struct face *,
398 Lisp_Object,
399 enum lface_attribute_index));
400static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *)); 396static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *));
401static void free_face_colors P_ ((struct frame *, struct face *)); 397static void free_face_colors P_ ((struct frame *, struct face *));
402static int face_color_gray_p P_ ((struct frame *, char *)); 398static int face_color_gray_p P_ ((struct frame *, char *));
@@ -1161,7 +1157,7 @@ COLOR must be a valid color name.")
1161 record that fact in flags of the face so that we don't try to free 1157 record that fact in flags of the face so that we don't try to free
1162 these colors. */ 1158 these colors. */
1163 1159
1164static unsigned long 1160unsigned long
1165load_color (f, face, name, target_index) 1161load_color (f, face, name, target_index)
1166 struct frame *f; 1162 struct frame *f;
1167 struct face *face; 1163 struct face *face;
@@ -1377,7 +1373,74 @@ free_face_colors (f, face)
1377 } 1373 }
1378} 1374}
1379 1375
1380#endif /* HAVE_X_WINDOWS */ 1376#else /* ! HAVE_X_WINDOWS */
1377
1378#ifdef MSDOS
1379unsigned long
1380load_color (f, face, name, target_index)
1381 struct frame *f;
1382 struct face *face;
1383 Lisp_Object name;
1384 enum lface_attribute_index target_index;
1385{
1386 Lisp_Object color;
1387 int color_idx = FACE_TTY_DEFAULT_COLOR;
1388
1389 if (NILP (name))
1390 return (unsigned long)FACE_TTY_DEFAULT_COLOR;
1391
1392 CHECK_STRING (name, 0);
1393
1394 color = Qnil;
1395 if (XSTRING (name)->size && !NILP (Ffboundp (Qmsdos_color_translate)))
1396 {
1397 color = call1 (Qmsdos_color_translate, name);
1398
1399 if (INTEGERP (color))
1400 return (unsigned long)XINT (color);
1401
1402 display_message (f, "Unable to load color %s", name, Qnil);
1403
1404 switch (target_index)
1405 {
1406 case LFACE_FOREGROUND_INDEX:
1407 face->foreground_defaulted_p = 1;
1408 color_idx = FRAME_FOREGROUND_PIXEL (f);
1409 break;
1410
1411 case LFACE_BACKGROUND_INDEX:
1412 face->background_defaulted_p = 1;
1413 color_idx = FRAME_BACKGROUND_PIXEL (f);
1414 break;
1415
1416 case LFACE_UNDERLINE_INDEX:
1417 face->underline_defaulted_p = 1;
1418 color_idx = FRAME_FOREGROUND_PIXEL (f);
1419 break;
1420
1421 case LFACE_OVERLINE_INDEX:
1422 face->overline_color_defaulted_p = 1;
1423 color_idx = FRAME_FOREGROUND_PIXEL (f);
1424 break;
1425
1426 case LFACE_STRIKE_THROUGH_INDEX:
1427 face->strike_through_color_defaulted_p = 1;
1428 color_idx = FRAME_FOREGROUND_PIXEL (f);
1429 break;
1430
1431 case LFACE_BOX_INDEX:
1432 face->box_color_defaulted_p = 1;
1433 color_idx = FRAME_FOREGROUND_PIXEL (f);
1434 break;
1435 }
1436 }
1437 else
1438 color_idx = msdos_stdcolor_idx (XSTRING (name)->data);
1439
1440 return (unsigned long)color_idx;
1441}
1442#endif /* MSDOS */
1443#endif /* ! HAVE_X_WINDOWS */
1381 1444
1382 1445
1383 1446
@@ -4234,7 +4297,7 @@ lookup_face (f, attr, charset)
4234 4297
4235 for (face = c->buckets[i]; face; face = face->next) 4298 for (face = c->buckets[i]; face; face = face->next)
4236 if (face->hash == hash 4299 if (face->hash == hash
4237 && (FRAME_TERMCAP_P (f) 4300 && (!FRAME_WINDOW_P (f)
4238 || FACE_SUITABLE_FOR_CHARSET_P (face, charset)) 4301 || FACE_SUITABLE_FOR_CHARSET_P (face, charset))
4239 && lface_equal_p (face->lface, attr)) 4302 && lface_equal_p (face->lface, attr))
4240 break; 4303 break;
@@ -4386,6 +4449,34 @@ face_with_height (f, face_id, height)
4386 return face_id; 4449 return face_id;
4387} 4450}
4388 4451
4452/* Return the face id of the realized face for named face SYMBOL on
4453 frame F suitable for displaying characters from CHARSET (CHARSET <
4454 0 means unibyte text), and use attributes of the face FACE_ID for
4455 attributes that aren't completely specified by SYMBOL. This is
4456 like lookup_named_face, except that the default attributes come
4457 from FACE_ID, not from the default face. FACE_ID is assumed to
4458 be already realized. */
4459
4460int
4461lookup_derived_face (f, symbol, charset, face_id)
4462 struct frame *f;
4463 Lisp_Object symbol;
4464 int charset;
4465 int face_id;
4466{
4467 Lisp_Object attrs[LFACE_VECTOR_SIZE];
4468 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
4469 struct face *default_face = FACE_FROM_ID (f, face_id);
4470
4471 if (!default_face)
4472 abort ();
4473
4474 get_lface_attributes (f, symbol, symbol_attrs, 1);
4475 bcopy (default_face->lface, attrs, sizeof attrs);
4476 merge_face_vectors (symbol_attrs, attrs);
4477 return lookup_face (f, attrs, charset);
4478}
4479
4389 4480
4390 4481
4391/*********************************************************************** 4482/***********************************************************************
@@ -5112,7 +5203,7 @@ realize_default_face (f)
5112 } 5203 }
5113#endif /* HAVE_X_WINDOWS */ 5204#endif /* HAVE_X_WINDOWS */
5114 5205
5115 if (FRAME_TERMCAP_P (f)) 5206 if (!FRAME_WINDOW_P (f))
5116 { 5207 {
5117 LFACE_FAMILY (lface) = build_string ("default"); 5208 LFACE_FAMILY (lface) = build_string ("default");
5118 LFACE_SWIDTH (lface) = Qnormal; 5209 LFACE_SWIDTH (lface) = Qnormal;
@@ -5146,7 +5237,7 @@ realize_default_face (f)
5146 LFACE_FOREGROUND (lface) = XCDR (color); 5237 LFACE_FOREGROUND (lface) = XCDR (color);
5147 else if (FRAME_X_P (f)) 5238 else if (FRAME_X_P (f))
5148 return 0; 5239 return 0;
5149 else if (FRAME_TERMCAP_P (f)) 5240 else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
5150 /* Frame parameters for terminal frames usually don't contain 5241 /* Frame parameters for terminal frames usually don't contain
5151 a color. Use an empty string to indicate that the face 5242 a color. Use an empty string to indicate that the face
5152 should use the (unknown) default color of the terminal. */ 5243 should use the (unknown) default color of the terminal. */
@@ -5164,7 +5255,7 @@ realize_default_face (f)
5164 LFACE_BACKGROUND (lface) = XCDR (color); 5255 LFACE_BACKGROUND (lface) = XCDR (color);
5165 else if (FRAME_X_P (f)) 5256 else if (FRAME_X_P (f))
5166 return 0; 5257 return 0;
5167 else if (FRAME_TERMCAP_P (f)) 5258 else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
5168 /* Frame parameters for terminal frames usually don't contain 5259 /* Frame parameters for terminal frames usually don't contain
5169 a color. Use an empty string to indicate that the face 5260 a color. Use an empty string to indicate that the face
5170 should use the (unknown) default color of the terminal. */ 5261 should use the (unknown) default color of the terminal. */
@@ -5182,6 +5273,18 @@ realize_default_face (f)
5182 bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs); 5273 bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs);
5183 face = realize_face (c, attrs, CHARSET_ASCII); 5274 face = realize_face (c, attrs, CHARSET_ASCII);
5184 5275
5276#ifdef MSDOS
5277 /* If either of the colors of the default face is the default color,
5278 use the color defined by the frame. */
5279 if (FRAME_MSDOS_P (f))
5280 {
5281 if (face->foreground == FACE_TTY_DEFAULT_COLOR)
5282 face->foreground = FRAME_FOREGROUND_PIXEL (f);
5283 if (face->background == FACE_TTY_DEFAULT_COLOR)
5284 face->background = FRAME_BACKGROUND_PIXEL (f);
5285 }
5286#endif
5287
5185 /* Remove the former default face. */ 5288 /* Remove the former default face. */
5186 if (c->used > DEFAULT_FACE_ID) 5289 if (c->used > DEFAULT_FACE_ID)
5187 { 5290 {
@@ -5265,7 +5368,7 @@ realize_face (c, attrs, charset)
5265 5368
5266 if (FRAME_X_P (c->f)) 5369 if (FRAME_X_P (c->f))
5267 face = realize_x_face (c, attrs, charset); 5370 face = realize_x_face (c, attrs, charset);
5268 else if (FRAME_TERMCAP_P (c->f)) 5371 else if (FRAME_TERMCAP_P (c->f) || FRAME_MSDOS_P (c->f))
5269 face = realize_tty_face (c, attrs, charset); 5372 face = realize_tty_face (c, attrs, charset);
5270 else 5373 else
5271 abort (); 5374 abort ();
@@ -5526,11 +5629,11 @@ realize_tty_face (c, attrs, charset)
5526 Lisp_Object color; 5629 Lisp_Object color;
5527 5630
5528 /* Frame must be a termcap frame. */ 5631 /* Frame must be a termcap frame. */
5529 xassert (FRAME_TERMCAP_P (c->f)); 5632 xassert (FRAME_TERMCAP_P (c->f) || FRAME_MSDOS_P (c->f));
5530 5633
5531 /* Allocate a new realized face. */ 5634 /* Allocate a new realized face. */
5532 face = make_realized_face (attrs, charset, Qnil); 5635 face = make_realized_face (attrs, charset, Qnil);
5533 face->font_name = "tty"; 5636 face->font_name = FRAME_MSDOS_P (c->f) ? "ms-dos" : "tty";
5534 5637
5535 /* Map face attributes to TTY appearances. We map slant to 5638 /* Map face attributes to TTY appearances. We map slant to
5536 dimmed text because we want italic text to appear differently 5639 dimmed text because we want italic text to appear differently
@@ -5556,12 +5659,35 @@ realize_tty_face (c, attrs, charset)
5556 CONSP (color))) 5659 CONSP (color)))
5557 face->foreground = XINT (XCDR (color)); 5660 face->foreground = XINT (XCDR (color));
5558 5661
5662#ifdef MSDOS
5663 if (FRAME_MSDOS_P (c->f) && face->foreground == FACE_TTY_DEFAULT_COLOR)
5664 face->foreground = load_color (c->f, face,
5665 attrs[LFACE_FOREGROUND_INDEX],
5666 LFACE_FOREGROUND_INDEX);
5667#endif
5668
5559 color = attrs[LFACE_BACKGROUND_INDEX]; 5669 color = attrs[LFACE_BACKGROUND_INDEX];
5560 if (XSTRING (color)->size 5670 if (XSTRING (color)->size
5561 && (color = Fassoc (color, Vface_tty_color_alist), 5671 && (color = Fassoc (color, Vface_tty_color_alist),
5562 CONSP (color))) 5672 CONSP (color)))
5563 face->background = XINT (XCDR (color)); 5673 face->background = XINT (XCDR (color));
5564 5674
5675#ifdef MSDOS
5676 if (FRAME_MSDOS_P (c->f) && face->background == FACE_TTY_DEFAULT_COLOR)
5677 face->background = load_color (c->f, face,
5678 attrs[LFACE_BACKGROUND_INDEX],
5679 LFACE_BACKGROUND_INDEX);
5680
5681 /* Swap colors if face is inverse-video. */
5682 if (face->tty_reverse_p)
5683 {
5684 unsigned long tem = face->foreground;
5685
5686 face->foreground = face->background;
5687 face->background = tem;
5688 }
5689#endif
5690
5565 return face; 5691 return face;
5566} 5692}
5567 5693