Mercurial > emacs
comparison src/xfaces.c @ 9572:b36d5e88cccc
*** empty log message ***
author | Morten Welinder <terra@diku.dk> |
---|---|
date | Mon, 17 Oct 1994 08:42:36 +0000 |
parents | fef2cfcbbe37 |
children | 5c7a3709e81a |
comparison
equal
deleted
inserted
replaced
9571:b37425ecb3f0 | 9572:b36d5e88cccc |
---|---|
23 #include <sys/stat.h> | 23 #include <sys/stat.h> |
24 | 24 |
25 #include <config.h> | 25 #include <config.h> |
26 #include "lisp.h" | 26 #include "lisp.h" |
27 | 27 |
28 #ifdef HAVE_FACES | |
29 | |
28 #ifdef HAVE_X_WINDOWS | 30 #ifdef HAVE_X_WINDOWS |
29 | |
30 #include "xterm.h" | 31 #include "xterm.h" |
32 #endif | |
33 #ifdef MSDOS | |
34 #include "dosfns.h" | |
35 #endif | |
31 #include "buffer.h" | 36 #include "buffer.h" |
32 #include "dispextern.h" | 37 #include "dispextern.h" |
33 #include "frame.h" | 38 #include "frame.h" |
34 #include "blockinput.h" | 39 #include "blockinput.h" |
35 #include "window.h" | 40 #include "window.h" |
36 #include "intervals.h" | 41 #include "intervals.h" |
37 | 42 |
43 #ifdef HAVE_X_WINDOWS | |
38 /* Compensate for bug in Xos.h on some systems, on which it requires | 44 /* Compensate for bug in Xos.h on some systems, on which it requires |
39 time.h. On some such systems, Xos.h tries to redefine struct | 45 time.h. On some such systems, Xos.h tries to redefine struct |
40 timeval and struct timezone if USG is #defined while it is | 46 timeval and struct timezone if USG is #defined while it is |
41 #included. */ | 47 #included. */ |
42 #ifdef XOS_NEEDS_TIME_H | 48 #ifdef XOS_NEEDS_TIME_H |
50 #else | 56 #else |
51 | 57 |
52 #include <X11/Xos.h> | 58 #include <X11/Xos.h> |
53 | 59 |
54 #endif | 60 #endif |
55 | 61 #endif /* HAVE_X_WINDOWS */ |
56 | 62 |
57 /* An explanation of the face data structures. */ | 63 /* An explanation of the face data structures. */ |
58 | 64 |
59 /* ========================= Face Data Structures ========================= | 65 /* ========================= Face Data Structures ========================= |
60 | 66 |
203 && face1->underline == face2->underline); | 209 && face1->underline == face2->underline); |
204 } | 210 } |
205 | 211 |
206 /* Managing graphics contexts of faces. */ | 212 /* Managing graphics contexts of faces. */ |
207 | 213 |
214 #ifdef HAVE_X_WINDOWS | |
208 /* Given a computed face, construct its graphics context if necessary. */ | 215 /* Given a computed face, construct its graphics context if necessary. */ |
209 | 216 |
210 struct face * | 217 struct face * |
211 intern_face (f, face) | 218 intern_face (f, face) |
212 struct frame *f; | 219 struct frame *f; |
452 *w_ptr = x_bitmap_width (f, bitmap_id); | 459 *w_ptr = x_bitmap_width (f, bitmap_id); |
453 *h_ptr = x_bitmap_height (f, bitmap_id); | 460 *h_ptr = x_bitmap_height (f, bitmap_id); |
454 | 461 |
455 return bitmap_id; | 462 return bitmap_id; |
456 } | 463 } |
464 | |
465 #else /* !HAVE_X_WINDOWS */ | |
466 | |
467 /* Stubs for MSDOS when not under X. */ | |
468 | |
469 struct face * | |
470 intern_face (f, face) | |
471 struct frame *f; | |
472 struct face *face; | |
473 { | |
474 return face; | |
475 } | |
476 | |
477 void | |
478 clear_face_cache () | |
479 { | |
480 /* No action. */ | |
481 } | |
482 | |
483 static void | |
484 build_face (f, face) | |
485 struct frame *f; | |
486 struct face *face; | |
487 { | |
488 face->gc = 1; | |
489 } | |
490 | |
491 #ifdef MSDOS | |
492 unsigned long | |
493 load_color (f, name) | |
494 FRAME_PTR f; | |
495 Lisp_Object name; | |
496 { | |
497 Lisp_Object result; | |
498 | |
499 if (NILP (name)) | |
500 return FACE_DEFAULT; | |
501 | |
502 CHECK_STRING (name, 0); | |
503 result = call1 (Qmsdos_color_translate, name); | |
504 if (INTEGERP (result)) | |
505 return XINT (result); | |
506 else | |
507 Fsignal (Qerror, Fcons (build_string ("undefined color"), | |
508 Fcons (name, Qnil))); | |
509 } | |
510 #endif | |
511 #endif /* !HAVE_X_WINDOWS */ | |
512 | |
457 | 513 |
458 /* Managing parameter face arrays for frames. */ | 514 /* Managing parameter face arrays for frames. */ |
459 | 515 |
460 void | 516 void |
461 init_frame_faces (f) | 517 init_frame_faces (f) |
469 | 525 |
470 new_computed_face (f, FRAME_PARAM_FACES (f)[0]); | 526 new_computed_face (f, FRAME_PARAM_FACES (f)[0]); |
471 new_computed_face (f, FRAME_PARAM_FACES (f)[1]); | 527 new_computed_face (f, FRAME_PARAM_FACES (f)[1]); |
472 recompute_basic_faces (f); | 528 recompute_basic_faces (f); |
473 | 529 |
530 #ifdef MULTI_FRAME | |
474 /* Find another X frame. */ | 531 /* Find another X frame. */ |
475 { | 532 { |
476 Lisp_Object tail, frame, result; | 533 Lisp_Object tail, frame, result; |
477 | 534 |
478 result = Qnil; | 535 result = Qnil; |
497 for (i = 2; i < n_faces; i++) | 554 for (i = 2; i < n_faces; i++) |
498 if (faces[i]) | 555 if (faces[i]) |
499 ensure_face_ready (f, i); | 556 ensure_face_ready (f, i); |
500 } | 557 } |
501 } | 558 } |
559 #endif /* MULTI_FRAME */ | |
502 } | 560 } |
503 | 561 |
504 | 562 |
505 /* Called from Fdelete_frame. */ | 563 /* Called from Fdelete_frame. */ |
506 | 564 |
625 | 683 |
626 if (FRAME_PARAM_FACES (f) [id] == 0) | 684 if (FRAME_PARAM_FACES (f) [id] == 0) |
627 FRAME_PARAM_FACES (f) [id] = allocate_face (); | 685 FRAME_PARAM_FACES (f) [id] = allocate_face (); |
628 } | 686 } |
629 | 687 |
688 #ifdef HAVE_X_WINDOWS | |
630 /* Return non-zero if FONT1 and FONT2 have the same width. | 689 /* Return non-zero if FONT1 and FONT2 have the same width. |
631 We do not check the height, because we can now deal with | 690 We do not check the height, because we can now deal with |
632 different heights. | 691 different heights. |
633 We assume that they're both character-cell fonts. */ | 692 We assume that they're both character-cell fonts. */ |
634 | 693 |
665 return 0; | 724 return 0; |
666 | 725 |
667 f->display.x->line_height = biggest; | 726 f->display.x->line_height = biggest; |
668 return 1; | 727 return 1; |
669 } | 728 } |
729 #endif /* not HAVE_X_WINDOWS */ | |
670 | 730 |
671 /* Modify face TO by copying from FROM all properties which have | 731 /* Modify face TO by copying from FROM all properties which have |
672 nondefault settings. */ | 732 nondefault settings. */ |
673 | 733 |
674 static void | 734 static void |
999 DEFUN ("make-face-internal", Fmake_face_internal, Smake_face_internal, 1, 1, 0, | 1059 DEFUN ("make-face-internal", Fmake_face_internal, Smake_face_internal, 1, 1, 0, |
1000 "Create face number FACE-ID on all frames.") | 1060 "Create face number FACE-ID on all frames.") |
1001 (face_id) | 1061 (face_id) |
1002 Lisp_Object face_id; | 1062 Lisp_Object face_id; |
1003 { | 1063 { |
1004 Lisp_Object rest; | 1064 Lisp_Object rest, frame; |
1005 int id = XINT (face_id); | 1065 int id = XINT (face_id); |
1006 | 1066 |
1007 CHECK_NUMBER (face_id, 0); | 1067 CHECK_NUMBER (face_id, 0); |
1008 if (id < 0 || id >= next_face_id) | 1068 if (id < 0 || id >= next_face_id) |
1009 error ("Face id out of range"); | 1069 error ("Face id out of range"); |
1010 | 1070 |
1011 for (rest = Vframe_list; !NILP (rest); rest = XCONS (rest)->cdr) | 1071 FOR_EACH_FRAME (rest, frame) |
1012 { | 1072 { |
1013 struct frame *f = XFRAME (XCONS (rest)->car); | 1073 if (FRAME_X_P (XFRAME (frame))) |
1014 if (FRAME_X_P (f)) | 1074 ensure_face_ready (XFRAME (frame), id); |
1015 ensure_face_ready (f, id); | |
1016 } | 1075 } |
1017 return Qnil; | 1076 return Qnil; |
1018 } | 1077 } |
1019 | 1078 |
1020 | 1079 |
1044 ensure_face_ready (f, id); | 1103 ensure_face_ready (f, id); |
1045 face = FRAME_PARAM_FACES (f) [XFASTINT (face_id)]; | 1104 face = FRAME_PARAM_FACES (f) [XFASTINT (face_id)]; |
1046 | 1105 |
1047 if (EQ (attr_name, intern ("font"))) | 1106 if (EQ (attr_name, intern ("font"))) |
1048 { | 1107 { |
1108 #if defined (MSDOS) && !defined (HAVE_X_WINDOWS) | |
1109 face->font = 0; /* The one and only font. */ | |
1110 #else | |
1049 XFontStruct *font = load_font (f, attr_value); | 1111 XFontStruct *font = load_font (f, attr_value); |
1050 if (face->font != f->display.x->font) | 1112 if (face->font != f->display.x->font) |
1051 unload_font (f, face->font); | 1113 unload_font (f, face->font); |
1052 face->font = font; | 1114 face->font = font; |
1053 if (frame_update_line_height (f)) | 1115 if (frame_update_line_height (f)) |
1054 x_set_window_size (f, 0, f->width, f->height); | 1116 x_set_window_size (f, 0, f->width, f->height); |
1055 /* Must clear cache, since it might contain the font | 1117 /* Must clear cache, since it might contain the font |
1056 we just got rid of. */ | 1118 we just got rid of. */ |
1057 garbaged = 1; | 1119 garbaged = 1; |
1120 #endif | |
1058 } | 1121 } |
1059 else if (EQ (attr_name, intern ("foreground"))) | 1122 else if (EQ (attr_name, intern ("foreground"))) |
1060 { | 1123 { |
1061 unsigned long new_color = load_color (f, attr_value); | 1124 unsigned long new_color = load_color (f, attr_value); |
1062 unload_color (f, face->foreground); | 1125 unload_color (f, face->foreground); |
1065 } | 1128 } |
1066 else if (EQ (attr_name, intern ("background"))) | 1129 else if (EQ (attr_name, intern ("background"))) |
1067 { | 1130 { |
1068 unsigned long new_color = load_color (f, attr_value); | 1131 unsigned long new_color = load_color (f, attr_value); |
1069 unload_color (f, face->background); | 1132 unload_color (f, face->background); |
1133 #if defined (MSDOS) && !defined (HAVE_X_WINDOWS) | |
1134 new_color &= ~8; /* Bright would give blinking characters. */ | |
1135 #endif | |
1070 face->background = new_color; | 1136 face->background = new_color; |
1071 garbaged = 1; | 1137 garbaged = 1; |
1072 } | 1138 } |
1073 else if (EQ (attr_name, intern ("background-pixmap"))) | 1139 else if (EQ (attr_name, intern ("background-pixmap"))) |
1074 { | 1140 { |
1145 DEFVAR_INT ("region-face", ®ion_face, | 1211 DEFVAR_INT ("region-face", ®ion_face, |
1146 "Face number to use to highlight the region\n\ | 1212 "Face number to use to highlight the region\n\ |
1147 The region is highlighted with this face\n\ | 1213 The region is highlighted with this face\n\ |
1148 when Transient Mark mode is enabled and the mark is active."); | 1214 when Transient Mark mode is enabled and the mark is active."); |
1149 | 1215 |
1216 #ifdef HAVE_X_WINDOWS | |
1150 defsubr (&Spixmap_spec_p); | 1217 defsubr (&Spixmap_spec_p); |
1218 #endif | |
1151 defsubr (&Sframe_face_alist); | 1219 defsubr (&Sframe_face_alist); |
1152 defsubr (&Sset_frame_face_alist); | 1220 defsubr (&Sset_frame_face_alist); |
1153 defsubr (&Smake_face_internal); | 1221 defsubr (&Smake_face_internal); |
1154 defsubr (&Sset_face_attribute_internal); | 1222 defsubr (&Sset_face_attribute_internal); |
1155 defsubr (&Sinternal_next_face_id); | 1223 defsubr (&Sinternal_next_face_id); |
1156 } | 1224 } |
1157 | 1225 |
1158 #endif /* HAVE_X_WINDOWS */ | 1226 #endif /* HAVE_FACES */ |
1159 |