diff options
| author | Eli Zaretskii | 1999-12-06 16:54:09 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 1999-12-06 16:54:09 +0000 |
| commit | 2d764c783d0ab96cc246f3bb1dad70f2ef56ce0f (patch) | |
| tree | fa1366f693555a3ec65273f478ed95babf1bd0a9 /src/xfaces.c | |
| parent | f6737cde3e786b0e8acea4b613aa42cf49fa204c (diff) | |
| download | emacs-2d764c783d0ab96cc246f3bb1dad70f2ef56ce0f.tar.gz emacs-2d764c783d0ab96cc246f3bb1dad70f2ef56ce0f.zip | |
Changes for automatic remapping of X colors on terminal frames:
* xfaces.c (XColor) [!HAVE_X_WINDOWS]: Provide a typedef for non-X
frames.
(Vface_tty_color_alist): Remove.
(tty_defined_color): New function.
(defined_color): Rewrite to support any type of frame.
(tty_color_name): New function.
(face_color_supported_p, Fface_color_gray_p,
Fface_color_supported_p): Support non-X frames.
(load_color): Enclose the color name in quotes, in the log
messages. Remove DOS-specific version of load_color.
(realize_tty_face): Take the supported colors from
tty-color-alist. Support translation of X colors to the closest
tty color, for both MSDOS and tty frames.
[MSDOS]: Don't invert face colors if they were taken from the
frame colors.
(Fface_register_tty_color, Fface_clear_tty_colors): Remove.
* frame.h (struct x_output) [!MSDOS, !WINDOWSNT, !HAVE_X_WINDOWS]:
Define a mostly empty surrogate.
(tty_display): Declare.
* frame.c (make_terminal_frame) [!macintosh]: Don't use
tty_display.
(Fframe_parameters): Don't invert colors of non-FRAME_WINDOW_P
frames when the frame's param_alist includes 'reverse.
(tty_display): Define.
(make_terminal_frame) [!MSDOS]: Assign &tty_display to the
output_data.x member.
(Fframe_parameters): Return foreground and background color names
on tty frames as well, in addition to MSDOS frames.
* msdos.h (DisplayWidth, DisplayHeight): Changes for Lisp_Object
selected_frame.
(struct x_output): Remove unused members; document who uses each
member.
(FRAME_PARAM_FACES, FRAME_N_PARAM_FACES, FRAME_DEFAULT_PARAM_FACE,
FRAME_MODE_LINE_PARAM_FACE, FRAME_COMPUTED_FACES,
FRAME_N_COMPUTED_FACES, FRAME_SIZE_COMPUTED_FACES,
FRAME_DEFAULT_FACE, FRAME_MODE_LINE_FACE, unload_color): Remove
unused macro definintions.
* msdos.c (IT_set_frame_parameters): Don't call
recompute_basic_faces, the next redisplay will, anyway.
(x_current_display): Remove unused variable.
Many functions: changes for Lisp_object selected_frame.
(IT_set_face): If the tty_reverse_p flag is set for the face,
reverse the foreground and background colors.
(Fmsdos_remember_default_colors): New function.
(syms_of_msdos): Defsubr it.
(IT_set_frame_parameters): Use initial_screen_colors[] when
creating a new frame. If the frame parameters include 'reverse,
swap the foreground and background colors.
(internal_terminal_init): Initialize initial_screen_colors to -1.
(syms_of_msdos): Add DEFVAR_BOOL for x-stretch-cursor, to shut up
cus-start.el.
* Makefile.in (lisp, shortlisp): Add lisp/term/tty-colors.elc.
* xfns.c (x_defined_color): Rename from defined_color. All
callers changed.
(Fxw_color_defined_p): Renamed from Fx_color_defined_p;
all callers changed.
(Fxw_color_values): Renamed from Fx_color_values; all callers
changed.
(Fxw_display_color_p): Renamed from Fx_display_color_p; all
callers changed.
(x_window_to_frame, x_any_window_to_frame,
x_non_menubar_window_to_frame, x_menubar_window_to_frame,
x_top_window_to_frame): Use !FRAME_X_P instead of
f->output_data.nothing.
* xterm.h (x_defined_color): Rename from defined_color.
* w32fns.c (x_window_to_frame): Use FRAME_W32_P instead of
f->output_data.nothing.
(Fxw_color_defined_p): Renamed from Fx_color_defined_p;
all callers changed.
(Fxw_color_values): Renamed from Fx_color_values; all callers
changed.
(Fxw_display_color_p): Renamed from Fx_display_color_p; all
callers changed.
* dispextern.h (tty_color_name): Add prototype.
* xmenu.c (menubar_id_to_frame): Use FRAME_WINDOW_P instead of
f->output_data.nothing.
* w32menu.c (menubar_id_to_frame): Likewise.
* w32term.h (w32_output): Declare.
* dosfns.c (Qmsdos_color_translate): Remove.
(msdos_stdcolor_name): Now returns a Lisp_Object.
* dosfns.h (Qmsdos_color_translate): Remove.
* s/msdos.h (INTERNAL_TERMINAL): Add entries for color support.
Diffstat (limited to 'src/xfaces.c')
| -rw-r--r-- | src/xfaces.c | 341 |
1 files changed, 176 insertions, 165 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index c7b9c1adf17..05a0d2dfe37 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -255,6 +255,16 @@ Boston, MA 02111-1307, USA. */ | |||
| 255 | 255 | ||
| 256 | #define FACE_CACHE_BUCKETS_SIZE 1001 | 256 | #define FACE_CACHE_BUCKETS_SIZE 1001 |
| 257 | 257 | ||
| 258 | /* A definition of XColor for non-X frames. */ | ||
| 259 | #ifndef HAVE_X_WINDOWS | ||
| 260 | typedef struct { | ||
| 261 | unsigned long pixel; | ||
| 262 | unsigned short red, green, blue; | ||
| 263 | char flags; | ||
| 264 | char pad; | ||
| 265 | } XColor; | ||
| 266 | #endif | ||
| 267 | |||
| 258 | /* Keyword symbols used for face attribute names. */ | 268 | /* Keyword symbols used for face attribute names. */ |
| 259 | 269 | ||
| 260 | Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline; | 270 | Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline; |
| @@ -368,10 +378,8 @@ static int next_lface_id; | |||
| 368 | static Lisp_Object *lface_id_to_name; | 378 | static Lisp_Object *lface_id_to_name; |
| 369 | static int lface_id_to_name_size; | 379 | static int lface_id_to_name_size; |
| 370 | 380 | ||
| 371 | /* An alist of elements (COLOR-NAME . INDEX) mapping color names | 381 | /* tty color-related functions (defined on lisp/term/tty-colors.el). */ |
| 372 | to color indices for tty frames. */ | 382 | Lisp_Object Qtty_color_desc, Qtty_color_by_index; |
| 373 | |||
| 374 | Lisp_Object Vface_tty_color_alist; | ||
| 375 | 383 | ||
| 376 | /* Counter for calls to clear_face_cache. If this counter reaches | 384 | /* Counter for calls to clear_face_cache. If this counter reaches |
| 377 | CLEAR_FONT_TABLE_COUNT, and a frame has more than | 385 | CLEAR_FONT_TABLE_COUNT, and a frame has more than |
| @@ -1067,7 +1075,113 @@ load_face_font_or_fontset (f, face, font_name, fontset) | |||
| 1067 | X Colors | 1075 | X Colors |
| 1068 | ***********************************************************************/ | 1076 | ***********************************************************************/ |
| 1069 | 1077 | ||
| 1078 | /* A version of defined_color for non-X frames. */ | ||
| 1079 | int | ||
| 1080 | tty_defined_color (f, color_name, color_def, alloc) | ||
| 1081 | struct frame *f; | ||
| 1082 | char *color_name; | ||
| 1083 | XColor *color_def; | ||
| 1084 | int alloc; | ||
| 1085 | { | ||
| 1086 | Lisp_Object color_desc; | ||
| 1087 | int color_idx = FACE_TTY_DEFAULT_COLOR, red = 0, green = 0, blue = 0; | ||
| 1088 | int status = 1; | ||
| 1089 | |||
| 1090 | if (*color_name && !NILP (Ffboundp (Qtty_color_desc))) | ||
| 1091 | { | ||
| 1092 | status = 0; | ||
| 1093 | color_desc = call1 (Qtty_color_desc, build_string (color_name)); | ||
| 1094 | if (!NILP (color_desc) && CONSP (color_desc)) | ||
| 1095 | { | ||
| 1096 | color_idx = XINT (XCAR (XCDR (color_desc))); | ||
| 1097 | if (CONSP (XCDR (XCDR (color_desc)))) | ||
| 1098 | { | ||
| 1099 | red = XINT (XCAR (XCDR (XCDR (color_desc)))); | ||
| 1100 | green = XINT (XCAR (XCDR (XCDR (XCDR (color_desc))))); | ||
| 1101 | blue = XINT (XCAR (XCDR (XCDR (XCDR (XCDR (color_desc)))))); | ||
| 1102 | } | ||
| 1103 | status = 1; | ||
| 1104 | } | ||
| 1105 | else if (NILP (Fsymbol_value (intern ("tty-color-alist")))) | ||
| 1106 | /* We were called early during startup, and the colors are not | ||
| 1107 | yet set up in tty-color-alist. Don't return a failure | ||
| 1108 | indication, since this produces the annoying "Unable to | ||
| 1109 | load color" messages in the *Messages* buffer. */ | ||
| 1110 | status = 1; | ||
| 1111 | } | ||
| 1112 | color_def->pixel = (unsigned long) color_idx; | ||
| 1113 | color_def->red = red; | ||
| 1114 | color_def->green = green; | ||
| 1115 | color_def->blue = blue; | ||
| 1116 | |||
| 1117 | return status; | ||
| 1118 | } | ||
| 1119 | |||
| 1120 | /* Decide if color named COLOR is valid for the display associated | ||
| 1121 | with the frame F; if so, return the rgb values in COLOR_DEF. If | ||
| 1122 | ALLOC is nonzero, allocate a new colormap cell. | ||
| 1123 | |||
| 1124 | This does the right thing for any type of frame. */ | ||
| 1125 | int | ||
| 1126 | defined_color (f, color_name, color_def, alloc) | ||
| 1127 | struct frame *f; | ||
| 1128 | char *color_name; | ||
| 1129 | XColor *color_def; | ||
| 1130 | int alloc; | ||
| 1131 | { | ||
| 1132 | if (!FRAME_WINDOW_P (f)) | ||
| 1133 | return tty_defined_color (f, color_name, color_def, alloc); | ||
| 1070 | #ifdef HAVE_X_WINDOWS | 1134 | #ifdef HAVE_X_WINDOWS |
| 1135 | else if (FRAME_X_P (f)) | ||
| 1136 | return x_defined_color (f, color_name, color_def, alloc); | ||
| 1137 | #endif | ||
| 1138 | #ifdef WINDOWSNT | ||
| 1139 | else if (FRAME_W32_P (f)) | ||
| 1140 | /* FIXME: w32_defined_color doesn't exist! w32fns.c defines | ||
| 1141 | defined_color which needs to be renamed, and the declaration | ||
| 1142 | of color_def therein should be changed. */ | ||
| 1143 | return w32_defined_color (f, color_name, color_def, alloc); | ||
| 1144 | #endif | ||
| 1145 | #ifdef macintosh | ||
| 1146 | else if (FRAME_MAC_P (f)) | ||
| 1147 | /* FIXME: mac_defined_color doesn't exist! */ | ||
| 1148 | return mac_defined_color (f, color_name, color_def, alloc); | ||
| 1149 | #endif | ||
| 1150 | else | ||
| 1151 | abort (); | ||
| 1152 | } | ||
| 1153 | |||
| 1154 | /* Given the index of the tty color, return its name, a Lisp string. */ | ||
| 1155 | |||
| 1156 | Lisp_Object | ||
| 1157 | tty_color_name (f, idx) | ||
| 1158 | struct frame *f; | ||
| 1159 | int idx; | ||
| 1160 | { | ||
| 1161 | char *color; | ||
| 1162 | |||
| 1163 | if (idx >= 0 && !NILP (Ffboundp (Qtty_color_by_index))) | ||
| 1164 | { | ||
| 1165 | Lisp_Object coldesc = call1 (Qtty_color_by_index, make_number (idx)); | ||
| 1166 | |||
| 1167 | if (!NILP (coldesc)) | ||
| 1168 | return XCAR (coldesc); | ||
| 1169 | } | ||
| 1170 | #ifdef MSDOS | ||
| 1171 | /* We can have an MSDOG frame under -nw for a short window of | ||
| 1172 | opportunity before internal_terminal_init is called. DTRT. */ | ||
| 1173 | if (FRAME_MSDOS_P (f) && !inhibit_window_system) | ||
| 1174 | return msdos_stdcolor_name (idx); | ||
| 1175 | #endif | ||
| 1176 | |||
| 1177 | #ifdef WINDOWSNT | ||
| 1178 | /* FIXME: When/if w32 supports colors in non-window mode, there should | ||
| 1179 | be a call here to a w32-specific function that returns the color | ||
| 1180 | by index using the default color mapping on a Windows console. */ | ||
| 1181 | #endif | ||
| 1182 | |||
| 1183 | return Qunspecified; | ||
| 1184 | } | ||
| 1071 | 1185 | ||
| 1072 | /* Return non-zero if COLOR_NAME is a shade of gray (or white or | 1186 | /* Return non-zero if COLOR_NAME is a shade of gray (or white or |
| 1073 | black) on frame F. The algorithm is taken from 20.2 faces.el. */ | 1187 | black) on frame F. The algorithm is taken from 20.2 faces.el. */ |
| @@ -1105,17 +1219,19 @@ face_color_supported_p (f, color_name, background_p) | |||
| 1105 | int background_p; | 1219 | int background_p; |
| 1106 | { | 1220 | { |
| 1107 | Lisp_Object frame; | 1221 | Lisp_Object frame; |
| 1222 | XColor not_used; | ||
| 1108 | 1223 | ||
| 1109 | XSETFRAME (frame, f); | 1224 | XSETFRAME (frame, f); |
| 1110 | return (!NILP (Vwindow_system) | 1225 | return ((FRAME_WINDOW_P (f) |
| 1111 | && (!NILP (Fx_display_color_p (frame)) | 1226 | && (!NILP (Fxw_display_color_p (frame)) |
| 1112 | || xstricmp (color_name, "black") == 0 | 1227 | || xstricmp (color_name, "black") == 0 |
| 1113 | || xstricmp (color_name, "white") == 0 | 1228 | || xstricmp (color_name, "white") == 0 |
| 1114 | || (background_p | 1229 | || (background_p |
| 1115 | && face_color_gray_p (f, color_name)) | 1230 | && face_color_gray_p (f, color_name)) |
| 1116 | || (!NILP (Fx_display_grayscale_p (frame)) | 1231 | || (!NILP (Fx_display_grayscale_p (frame)) |
| 1117 | && face_color_gray_p (f, color_name)))); | 1232 | && face_color_gray_p (f, color_name)))) |
| 1118 | } | 1233 | || tty_defined_color (f, color_name, ¬_used, 0)); |
| 1234 | } | ||
| 1119 | 1235 | ||
| 1120 | 1236 | ||
| 1121 | DEFUN ("face-color-gray-p", Fface_color_gray_p, Sface_color_gray_p, 1, 2, 0, | 1237 | DEFUN ("face-color-gray-p", Fface_color_gray_p, Sface_color_gray_p, 1, 2, 0, |
| @@ -1125,8 +1241,11 @@ If FRAME is nil or omitted, use the selected frame.") | |||
| 1125 | (color, frame) | 1241 | (color, frame) |
| 1126 | Lisp_Object color, frame; | 1242 | Lisp_Object color, frame; |
| 1127 | { | 1243 | { |
| 1128 | struct frame *f = check_x_frame (frame); | 1244 | struct frame *f; |
| 1245 | |||
| 1246 | CHECK_FRAME (frame, 0); | ||
| 1129 | CHECK_STRING (color, 0); | 1247 | CHECK_STRING (color, 0); |
| 1248 | f = XFRAME (frame); | ||
| 1130 | return face_color_gray_p (f, XSTRING (color)->data) ? Qt : Qnil; | 1249 | return face_color_gray_p (f, XSTRING (color)->data) ? Qt : Qnil; |
| 1131 | } | 1250 | } |
| 1132 | 1251 | ||
| @@ -1140,8 +1259,11 @@ COLOR must be a valid color name.") | |||
| 1140 | (frame, color, background_p) | 1259 | (frame, color, background_p) |
| 1141 | Lisp_Object frame, color, background_p; | 1260 | Lisp_Object frame, color, background_p; |
| 1142 | { | 1261 | { |
| 1143 | struct frame *f = check_x_frame (frame); | 1262 | struct frame *f; |
| 1263 | |||
| 1264 | CHECK_FRAME (frame, 0); | ||
| 1144 | CHECK_STRING (color, 0); | 1265 | CHECK_STRING (color, 0); |
| 1266 | f = XFRAME (frame); | ||
| 1145 | if (face_color_supported_p (f, XSTRING (color)->data, !NILP (background_p))) | 1267 | if (face_color_supported_p (f, XSTRING (color)->data, !NILP (background_p))) |
| 1146 | return Qt; | 1268 | return Qt; |
| 1147 | return Qnil; | 1269 | return Qnil; |
| @@ -1177,7 +1299,7 @@ load_color (f, face, name, target_index) | |||
| 1177 | to the values in an existing cell. */ | 1299 | to the values in an existing cell. */ |
| 1178 | if (!defined_color (f, XSTRING (name)->data, &color, 1)) | 1300 | if (!defined_color (f, XSTRING (name)->data, &color, 1)) |
| 1179 | { | 1301 | { |
| 1180 | add_to_log ("Unable to load color %s", name, Qnil); | 1302 | add_to_log ("Unable to load color \"%s\"", name, Qnil); |
| 1181 | 1303 | ||
| 1182 | switch (target_index) | 1304 | switch (target_index) |
| 1183 | { | 1305 | { |
| @@ -1223,6 +1345,7 @@ load_color (f, face, name, target_index) | |||
| 1223 | return color.pixel; | 1345 | return color.pixel; |
| 1224 | } | 1346 | } |
| 1225 | 1347 | ||
| 1348 | #ifdef HAVE_X_WINDOWS | ||
| 1226 | 1349 | ||
| 1227 | /* Load colors for face FACE which is used on frame F. Colors are | 1350 | /* Load colors for face FACE which is used on frame F. Colors are |
| 1228 | specified by slots LFACE_BACKGROUND_INDEX and LFACE_FOREGROUND_INDEX | 1351 | specified by slots LFACE_BACKGROUND_INDEX and LFACE_FOREGROUND_INDEX |
| @@ -1371,75 +1494,7 @@ free_face_colors (f, face) | |||
| 1371 | UNBLOCK_INPUT; | 1494 | UNBLOCK_INPUT; |
| 1372 | } | 1495 | } |
| 1373 | } | 1496 | } |
| 1374 | 1497 | #endif /* HAVE_X_WINDOWS */ | |
| 1375 | #else /* ! HAVE_X_WINDOWS */ | ||
| 1376 | |||
| 1377 | #ifdef MSDOS | ||
| 1378 | unsigned long | ||
| 1379 | load_color (f, face, name, target_index) | ||
| 1380 | struct frame *f; | ||
| 1381 | struct face *face; | ||
| 1382 | Lisp_Object name; | ||
| 1383 | enum lface_attribute_index target_index; | ||
| 1384 | { | ||
| 1385 | Lisp_Object color; | ||
| 1386 | int color_idx = FACE_TTY_DEFAULT_COLOR; | ||
| 1387 | |||
| 1388 | if (NILP (name)) | ||
| 1389 | return (unsigned long)FACE_TTY_DEFAULT_COLOR; | ||
| 1390 | |||
| 1391 | CHECK_STRING (name, 0); | ||
| 1392 | |||
| 1393 | color = Qnil; | ||
| 1394 | if (XSTRING (name)->size && !NILP (Ffboundp (Qmsdos_color_translate))) | ||
| 1395 | { | ||
| 1396 | color = call1 (Qmsdos_color_translate, name); | ||
| 1397 | |||
| 1398 | if (INTEGERP (color)) | ||
| 1399 | return (unsigned long)XINT (color); | ||
| 1400 | |||
| 1401 | add_to_log ("Unable to load color %s", name, Qnil); | ||
| 1402 | |||
| 1403 | switch (target_index) | ||
| 1404 | { | ||
| 1405 | case LFACE_FOREGROUND_INDEX: | ||
| 1406 | face->foreground_defaulted_p = 1; | ||
| 1407 | color_idx = FRAME_FOREGROUND_PIXEL (f); | ||
| 1408 | break; | ||
| 1409 | |||
| 1410 | case LFACE_BACKGROUND_INDEX: | ||
| 1411 | face->background_defaulted_p = 1; | ||
| 1412 | color_idx = FRAME_BACKGROUND_PIXEL (f); | ||
| 1413 | break; | ||
| 1414 | |||
| 1415 | case LFACE_UNDERLINE_INDEX: | ||
| 1416 | face->underline_defaulted_p = 1; | ||
| 1417 | color_idx = FRAME_FOREGROUND_PIXEL (f); | ||
| 1418 | break; | ||
| 1419 | |||
| 1420 | case LFACE_OVERLINE_INDEX: | ||
| 1421 | face->overline_color_defaulted_p = 1; | ||
| 1422 | color_idx = FRAME_FOREGROUND_PIXEL (f); | ||
| 1423 | break; | ||
| 1424 | |||
| 1425 | case LFACE_STRIKE_THROUGH_INDEX: | ||
| 1426 | face->strike_through_color_defaulted_p = 1; | ||
| 1427 | color_idx = FRAME_FOREGROUND_PIXEL (f); | ||
| 1428 | break; | ||
| 1429 | |||
| 1430 | case LFACE_BOX_INDEX: | ||
| 1431 | face->box_color_defaulted_p = 1; | ||
| 1432 | color_idx = FRAME_FOREGROUND_PIXEL (f); | ||
| 1433 | break; | ||
| 1434 | } | ||
| 1435 | } | ||
| 1436 | else | ||
| 1437 | color_idx = msdos_stdcolor_idx (XSTRING (name)->data); | ||
| 1438 | |||
| 1439 | return (unsigned long)color_idx; | ||
| 1440 | } | ||
| 1441 | #endif /* MSDOS */ | ||
| 1442 | #endif /* ! HAVE_X_WINDOWS */ | ||
| 1443 | 1498 | ||
| 1444 | 1499 | ||
| 1445 | 1500 | ||
| @@ -2714,7 +2769,7 @@ lface_fully_specified_p (attrs) | |||
| 2714 | for split_font_name, see the comment there. */ | 2769 | for split_font_name, see the comment there. */ |
| 2715 | 2770 | ||
| 2716 | static int | 2771 | static int |
| 2717 | set_lface_from_font_name (f, lface, font_name, force_p, may_fail_p) | 2772 | set_lface_from_font_name (f, lface, font_name, force_p) |
| 2718 | struct frame *f; | 2773 | struct frame *f; |
| 2719 | Lisp_Object lface; | 2774 | Lisp_Object lface; |
| 2720 | char *font_name; | 2775 | char *font_name; |
| @@ -2752,10 +2807,8 @@ set_lface_from_font_name (f, lface, font_name, force_p, may_fail_p) | |||
| 2752 | split_font_name (f, &font, 1); | 2807 | split_font_name (f, &font, 1); |
| 2753 | have_font_p = 1; | 2808 | have_font_p = 1; |
| 2754 | } | 2809 | } |
| 2755 | |||
| 2756 | UNBLOCK_INPUT; | 2810 | UNBLOCK_INPUT; |
| 2757 | } | 2811 | } |
| 2758 | } | ||
| 2759 | 2812 | ||
| 2760 | /* If FONT_NAME is completely bogus try to use something reasonable | 2813 | /* If FONT_NAME is completely bogus try to use something reasonable |
| 2761 | if this function must succeed. Otherwise, give up. */ | 2814 | if this function must succeed. Otherwise, give up. */ |
| @@ -5628,12 +5681,7 @@ realize_default_face (f) | |||
| 5628 | LFACE_FOREGROUND (lface) = XCDR (color); | 5681 | LFACE_FOREGROUND (lface) = XCDR (color); |
| 5629 | else if (FRAME_X_P (f)) | 5682 | else if (FRAME_X_P (f)) |
| 5630 | return 0; | 5683 | return 0; |
| 5631 | else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) | 5684 | else if (!FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f)) |
| 5632 | /* Frame parameters for terminal frames usually don't contain | ||
| 5633 | a color. Use an empty string to indicate that the face | ||
| 5634 | should use the (unknown) default color of the terminal. */ | ||
| 5635 | LFACE_FOREGROUND (lface) = build_string (""); | ||
| 5636 | else | ||
| 5637 | abort (); | 5685 | abort (); |
| 5638 | } | 5686 | } |
| 5639 | 5687 | ||
| @@ -5646,12 +5694,7 @@ realize_default_face (f) | |||
| 5646 | LFACE_BACKGROUND (lface) = XCDR (color); | 5694 | LFACE_BACKGROUND (lface) = XCDR (color); |
| 5647 | else if (FRAME_X_P (f)) | 5695 | else if (FRAME_X_P (f)) |
| 5648 | return 0; | 5696 | return 0; |
| 5649 | else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) | 5697 | else if (!FRAME_TERMCAP_P (f) && !FRAME_MSDOS_P (f)) |
| 5650 | /* Frame parameters for terminal frames usually don't contain | ||
| 5651 | a color. Use an empty string to indicate that the face | ||
| 5652 | should use the (unknown) default color of the terminal. */ | ||
| 5653 | LFACE_BACKGROUND (lface) = build_string (""); | ||
| 5654 | else | ||
| 5655 | abort (); | 5698 | abort (); |
| 5656 | } | 5699 | } |
| 5657 | 5700 | ||
| @@ -6006,6 +6049,8 @@ realize_tty_face (c, attrs, charset) | |||
| 6006 | struct face *face; | 6049 | struct face *face; |
| 6007 | int weight, slant; | 6050 | int weight, slant; |
| 6008 | Lisp_Object color; | 6051 | Lisp_Object color; |
| 6052 | Lisp_Object tty_color_alist = Fsymbol_value (intern ("tty-color-alist")); | ||
| 6053 | int face_colors_defaulted = 0; | ||
| 6009 | 6054 | ||
| 6010 | /* Frame must be a termcap frame. */ | 6055 | /* Frame must be a termcap frame. */ |
| 6011 | xassert (FRAME_TERMCAP_P (c->f) || FRAME_MSDOS_P (c->f)); | 6056 | xassert (FRAME_TERMCAP_P (c->f) || FRAME_MSDOS_P (c->f)); |
| @@ -6033,109 +6078,78 @@ realize_tty_face (c, attrs, charset) | |||
| 6033 | face->foreground = face->background = FACE_TTY_DEFAULT_COLOR; | 6078 | face->foreground = face->background = FACE_TTY_DEFAULT_COLOR; |
| 6034 | 6079 | ||
| 6035 | color = attrs[LFACE_FOREGROUND_INDEX]; | 6080 | color = attrs[LFACE_FOREGROUND_INDEX]; |
| 6036 | if (XSTRING (color)->size | 6081 | if (STRINGP (color) |
| 6037 | && (color = Fassoc (color, Vface_tty_color_alist), | 6082 | && XSTRING (color)->size |
| 6083 | && !NILP (tty_color_alist) | ||
| 6084 | && (color = Fassoc (color, tty_color_alist), | ||
| 6038 | CONSP (color))) | 6085 | CONSP (color))) |
| 6039 | face->foreground = XINT (XCDR (color)); | 6086 | /* Associations in tty-color-alist are of the form |
| 6087 | (NAME INDEX R G B). We need the INDEX part. */ | ||
| 6088 | face->foreground = XINT (XCAR (XCDR (color))); | ||
| 6040 | 6089 | ||
| 6041 | #ifdef MSDOS | 6090 | if (face->foreground == FACE_TTY_DEFAULT_COLOR |
| 6042 | if (FRAME_MSDOS_P (c->f) && face->foreground == FACE_TTY_DEFAULT_COLOR) | 6091 | && STRINGP (attrs[LFACE_FOREGROUND_INDEX])) |
| 6043 | { | 6092 | { |
| 6044 | face->foreground = load_color (c->f, face, | 6093 | face->foreground = load_color (c->f, face, |
| 6045 | attrs[LFACE_FOREGROUND_INDEX], | 6094 | attrs[LFACE_FOREGROUND_INDEX], |
| 6046 | LFACE_FOREGROUND_INDEX); | 6095 | LFACE_FOREGROUND_INDEX); |
| 6096 | #ifdef MSDOS | ||
| 6047 | /* If the foreground of the default face is the default color, | 6097 | /* If the foreground of the default face is the default color, |
| 6048 | use the foreground color defined by the frame. */ | 6098 | use the foreground color defined by the frame. */ |
| 6049 | if (face->foreground == FACE_TTY_DEFAULT_COLOR) | 6099 | if (FRAME_MSDOS_P (c->f) && face->foreground == FACE_TTY_DEFAULT_COLOR) |
| 6050 | { | 6100 | { |
| 6051 | face->foreground = FRAME_FOREGROUND_PIXEL (f); | 6101 | face->foreground = FRAME_FOREGROUND_PIXEL (f); |
| 6052 | attrs[LFACE_FOREGROUND_INDEX] = | 6102 | attrs[LFACE_FOREGROUND_INDEX] = |
| 6053 | build_string (msdos_stdcolor_name (face->foreground)); | 6103 | msdos_stdcolor_name (face->foreground); |
| 6104 | face_colors_defaulted = 1; | ||
| 6054 | } | 6105 | } |
| 6055 | } | ||
| 6056 | #endif | 6106 | #endif |
| 6107 | } | ||
| 6057 | 6108 | ||
| 6058 | color = attrs[LFACE_BACKGROUND_INDEX]; | 6109 | color = attrs[LFACE_BACKGROUND_INDEX]; |
| 6059 | if (XSTRING (color)->size | 6110 | if (STRINGP (color) |
| 6060 | && (color = Fassoc (color, Vface_tty_color_alist), | 6111 | && XSTRING (color)->size |
| 6112 | && !NILP (tty_color_alist) | ||
| 6113 | && (color = Fassoc (color, tty_color_alist), | ||
| 6061 | CONSP (color))) | 6114 | CONSP (color))) |
| 6062 | face->background = XINT (XCDR (color)); | 6115 | /* Associations in tty-color-alist are of the form |
| 6116 | (NAME INDEX R G B). We need the INDEX part. */ | ||
| 6117 | face->background = XINT (XCAR (XCDR (color))); | ||
| 6063 | 6118 | ||
| 6064 | #ifdef MSDOS | 6119 | if (face->background == FACE_TTY_DEFAULT_COLOR |
| 6065 | if (FRAME_MSDOS_P (c->f) && face->background == FACE_TTY_DEFAULT_COLOR) | 6120 | && STRINGP (attrs[LFACE_BACKGROUND_INDEX])) |
| 6066 | { | 6121 | { |
| 6067 | face->background = load_color (c->f, face, | 6122 | face->background = load_color (c->f, face, |
| 6068 | attrs[LFACE_BACKGROUND_INDEX], | 6123 | attrs[LFACE_BACKGROUND_INDEX], |
| 6069 | LFACE_BACKGROUND_INDEX); | 6124 | LFACE_BACKGROUND_INDEX); |
| 6125 | #ifdef MSDOS | ||
| 6070 | /* If the background of the default face is the default color, | 6126 | /* If the background of the default face is the default color, |
| 6071 | use the background color defined by the frame. */ | 6127 | use the background color defined by the frame. */ |
| 6072 | if (face->background == FACE_TTY_DEFAULT_COLOR) | 6128 | if (FRAME_MSDOS_P (c->f) && face->background == FACE_TTY_DEFAULT_COLOR) |
| 6073 | { | 6129 | { |
| 6074 | face->background = FRAME_BACKGROUND_PIXEL (f); | 6130 | face->background = FRAME_BACKGROUND_PIXEL (f); |
| 6075 | attrs[LFACE_BACKGROUND_INDEX] = | 6131 | attrs[LFACE_BACKGROUND_INDEX] = |
| 6076 | build_string (msdos_stdcolor_name (face->background)); | 6132 | msdos_stdcolor_name (face->background); |
| 6133 | face_colors_defaulted = 1; | ||
| 6077 | } | 6134 | } |
| 6135 | #endif | ||
| 6078 | } | 6136 | } |
| 6079 | 6137 | ||
| 6080 | /* Swap colors if face is inverse-video. */ | 6138 | /* Swap colors if face is inverse-video. If the colors are taken |
| 6081 | if (face->tty_reverse_p) | 6139 | from the frame colors, they are already inverted, since the |
| 6140 | frame-creation function calls x-handle-reverse-video. */ | ||
| 6141 | if (face->tty_reverse_p && !face_colors_defaulted) | ||
| 6082 | { | 6142 | { |
| 6083 | unsigned long tem = face->foreground; | 6143 | unsigned long tem = face->foreground; |
| 6084 | 6144 | ||
| 6085 | face->foreground = face->background; | 6145 | face->foreground = face->background; |
| 6086 | face->background = tem; | 6146 | face->background = tem; |
| 6087 | } | 6147 | } |
| 6088 | #endif | ||
| 6089 | 6148 | ||
| 6090 | return face; | 6149 | return face; |
| 6091 | } | 6150 | } |
| 6092 | 6151 | ||
| 6093 | 6152 | ||
| 6094 | DEFUN ("face-register-tty-color", Fface_register_tty_color, | ||
| 6095 | Sface_register_tty_color, 2, 2, 0, | ||
| 6096 | "Say that COLOR is color number NUMBER on the terminal.\n\ | ||
| 6097 | COLOR is a string, the color name. Value is COLOR.") | ||
| 6098 | (color, number) | ||
| 6099 | Lisp_Object color, number; | ||
| 6100 | { | ||
| 6101 | Lisp_Object entry; | ||
| 6102 | |||
| 6103 | CHECK_STRING (color, 0); | ||
| 6104 | CHECK_NUMBER (number, 1); | ||
| 6105 | entry = Fassoc (color, Vface_tty_color_alist); | ||
| 6106 | if (NILP (entry)) | ||
| 6107 | Vface_tty_color_alist = Fcons (Fcons (color, number), | ||
| 6108 | Vface_tty_color_alist); | ||
| 6109 | else | ||
| 6110 | Fsetcdr (entry, number); | ||
| 6111 | return color; | ||
| 6112 | } | ||
| 6113 | |||
| 6114 | |||
| 6115 | DEFUN ("face-clear-tty-colors", Fface_clear_tty_colors, | ||
| 6116 | Sface_clear_tty_colors, 0, 0, 0, | ||
| 6117 | "Unregister all registered tty colors.") | ||
| 6118 | () | ||
| 6119 | { | ||
| 6120 | return Vface_tty_color_alist = Qnil; | ||
| 6121 | } | ||
| 6122 | |||
| 6123 | |||
| 6124 | DEFUN ("tty-defined-colors", Ftty_defined_colors, | ||
| 6125 | Stty_defined_colors, 0, 0, 0, | ||
| 6126 | "Return a list of registered tty colors.") | ||
| 6127 | () | ||
| 6128 | { | ||
| 6129 | Lisp_Object list, colors; | ||
| 6130 | |||
| 6131 | colors = Qnil; | ||
| 6132 | for (list = Vface_tty_color_alist; CONSP (list); list = XCDR (list)) | ||
| 6133 | colors = Fcons (XCAR (XCAR (list)), colors); | ||
| 6134 | |||
| 6135 | return colors; | ||
| 6136 | } | ||
| 6137 | |||
| 6138 | |||
| 6139 | 6153 | ||
| 6140 | /*********************************************************************** | 6154 | /*********************************************************************** |
| 6141 | Computing Faces | 6155 | Computing Faces |
| @@ -6625,6 +6639,10 @@ syms_of_xfaces () | |||
| 6625 | staticpro (&Qborder); | 6639 | staticpro (&Qborder); |
| 6626 | Qmouse = intern ("mouse"); | 6640 | Qmouse = intern ("mouse"); |
| 6627 | staticpro (&Qmouse); | 6641 | staticpro (&Qmouse); |
| 6642 | Qtty_color_desc = intern ("tty-color-desc"); | ||
| 6643 | staticpro (&Qtty_color_desc); | ||
| 6644 | Qtty_color_by_index = intern ("tty-color-by-index"); | ||
| 6645 | staticpro (&Qtty_color_by_index); | ||
| 6628 | 6646 | ||
| 6629 | defsubr (&Sinternal_make_lisp_face); | 6647 | defsubr (&Sinternal_make_lisp_face); |
| 6630 | defsubr (&Sinternal_lisp_face_p); | 6648 | defsubr (&Sinternal_lisp_face_p); |
| @@ -6696,11 +6714,4 @@ scaled if its name matches a regular expression in the list."); | |||
| 6696 | defsubr (&Sx_family_fonts); | 6714 | defsubr (&Sx_family_fonts); |
| 6697 | defsubr (&Sx_font_family_list); | 6715 | defsubr (&Sx_font_family_list); |
| 6698 | #endif /* HAVE_X_WINDOWS */ | 6716 | #endif /* HAVE_X_WINDOWS */ |
| 6699 | |||
| 6700 | /* TTY face support. */ | ||
| 6701 | defsubr (&Sface_register_tty_color); | ||
| 6702 | defsubr (&Sface_clear_tty_colors); | ||
| 6703 | defsubr (&Stty_defined_colors); | ||
| 6704 | Vface_tty_color_alist = Qnil; | ||
| 6705 | staticpro (&Vface_tty_color_alist); | ||
| 6706 | } | 6717 | } |