Mercurial > emacs
comparison src/msdos.c @ 32546:9672c4db6bed
(IT_set_face): Compare highlighted face with the default
face, and invert colors if these faces' colors are identical.
(Fmsdos_remember_default_colors): Don't swap foreground and
background colors in initial_colors[].
(IT_set_frame_parameters): Don't swap frame's foreground and
background pixels. If ALIST includes "(reverse . t)", swap
foreground-color and background-color properties in frame's
param_alist. If the original frame's param_alist doesn't specify
the colors, store unspecified-fg and unspecified-bg, reversed if
required.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Mon, 16 Oct 2000 19:16:20 +0000 |
parents | a9dbff7d4142 |
children | 5d98418d7b78 |
comparison
equal
deleted
inserted
replaced
32545:288723d38c06 | 32546:9672c4db6bed |
---|---|
862 the video RAM. */ | 862 the video RAM. */ |
863 static void | 863 static void |
864 IT_set_face (int face) | 864 IT_set_face (int face) |
865 { | 865 { |
866 struct frame *sf = SELECTED_FRAME(); | 866 struct frame *sf = SELECTED_FRAME(); |
867 struct face *fp = FACE_FROM_ID (sf, face); | 867 struct face *fp = FACE_FROM_ID (sf, face); |
868 unsigned long fg, bg; | 868 struct face *dfp = FACE_FROM_ID (sf, DEFAULT_FACE_ID); |
869 unsigned long fg, bg, dflt_fg, dflt_bg; | |
869 | 870 |
870 if (!fp) | 871 if (!fp) |
871 { | 872 { |
872 fp = FACE_FROM_ID (sf, DEFAULT_FACE_ID); | 873 fp = dfp; |
873 /* The default face for the frame should always be realized and | 874 /* The default face for the frame should always be realized and |
874 cached. */ | 875 cached. */ |
875 if (!fp) | 876 if (!fp) |
876 abort (); | 877 abort (); |
877 } | 878 } |
878 screen_face = face; | 879 screen_face = face; |
879 fg = fp->foreground; | 880 fg = fp->foreground; |
880 bg = fp->background; | 881 bg = fp->background; |
882 dflt_fg = dfp->foreground; | |
883 dflt_bg = dfp->background; | |
881 | 884 |
882 /* Don't use invalid colors. In particular, FACE_TTY_DEFAULT_* | 885 /* Don't use invalid colors. In particular, FACE_TTY_DEFAULT_* |
883 colors mean use the colors of the default face, except that if | 886 colors mean use the colors of the default face, except that if |
884 highlight is on, invert the foreground and the background. Note | 887 highlight is on, invert the foreground and the background. Note |
885 that we assume all 16 colors to be available for the background, | 888 that we assume all 16 colors to be available for the background, |
894 else if (bg == FACE_TTY_DEFAULT_FG_COLOR) | 897 else if (bg == FACE_TTY_DEFAULT_FG_COLOR) |
895 bg = FRAME_FOREGROUND_PIXEL (sf); | 898 bg = FRAME_FOREGROUND_PIXEL (sf); |
896 | 899 |
897 /* Make sure highlighted lines really stand out, come what may. */ | 900 /* Make sure highlighted lines really stand out, come what may. */ |
898 if ((highlight || fp->tty_reverse_p) | 901 if ((highlight || fp->tty_reverse_p) |
899 && (fg == FRAME_FOREGROUND_PIXEL (sf) | 902 && (fg == dflt_fg && bg == dflt_bg)) |
900 && bg == FRAME_BACKGROUND_PIXEL (sf))) | |
901 { | 903 { |
902 unsigned long tem = fg; | 904 unsigned long tem = fg; |
903 | 905 |
904 fg = bg; | 906 fg = bg; |
905 bg = tem; | 907 bg = tem; |
2269 Smsdos_remember_default_colors, 1, 1, 0, | 2271 Smsdos_remember_default_colors, 1, 1, 0, |
2270 "Remember the screen colors of the current frame.") | 2272 "Remember the screen colors of the current frame.") |
2271 (frame) | 2273 (frame) |
2272 Lisp_Object frame; | 2274 Lisp_Object frame; |
2273 { | 2275 { |
2274 int reverse; | |
2275 struct frame *f; | 2276 struct frame *f; |
2276 | 2277 |
2277 CHECK_FRAME (frame, 0); | 2278 CHECK_FRAME (frame, 0); |
2278 f= XFRAME (frame); | 2279 f= XFRAME (frame); |
2279 reverse = EQ (Fcdr (Fassq (intern ("reverse"), f->param_alist)), Qt); | 2280 |
2280 | 2281 initial_screen_colors[0] = FRAME_FOREGROUND_PIXEL (f); |
2281 initial_screen_colors[0] | 2282 initial_screen_colors[1] = FRAME_BACKGROUND_PIXEL (f); |
2282 = reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f); | |
2283 initial_screen_colors[1] | |
2284 = reverse ? FRAME_FOREGROUND_PIXEL (f) : FRAME_BACKGROUND_PIXEL (f); | |
2285 } | 2283 } |
2286 | 2284 |
2287 void | 2285 void |
2288 IT_set_frame_parameters (f, alist) | 2286 IT_set_frame_parameters (f, alist) |
2289 struct frame *f; | 2287 struct frame *f; |
2298 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); | 2296 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); |
2299 /* Do we have to reverse the foreground and background colors? */ | 2297 /* Do we have to reverse the foreground and background colors? */ |
2300 int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt); | 2298 int reverse = EQ (Fcdr (Fassq (Qreverse, f->param_alist)), Qt); |
2301 int was_reverse = reverse; | 2299 int was_reverse = reverse; |
2302 int redraw = 0, fg_set = 0, bg_set = 0; | 2300 int redraw = 0, fg_set = 0, bg_set = 0; |
2301 int need_to_reverse; | |
2303 unsigned long orig_fg; | 2302 unsigned long orig_fg; |
2304 unsigned long orig_bg; | 2303 unsigned long orig_bg; |
2304 Lisp_Object frame_bg, frame_fg; | |
2305 extern Lisp_Object Qdefault, QCforeground, QCbackground; | 2305 extern Lisp_Object Qdefault, QCforeground, QCbackground; |
2306 | 2306 |
2307 /* If we are creating a new frame, begin with the original screen colors | 2307 /* If we are creating a new frame, begin with the original screen colors |
2308 used for the initial frame. */ | 2308 used for the initial frame. */ |
2309 if (alist == Vdefault_frame_alist | 2309 if (alist == Vdefault_frame_alist |
2312 FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0]; | 2312 FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0]; |
2313 FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1]; | 2313 FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1]; |
2314 } | 2314 } |
2315 orig_fg = FRAME_FOREGROUND_PIXEL (f); | 2315 orig_fg = FRAME_FOREGROUND_PIXEL (f); |
2316 orig_bg = FRAME_BACKGROUND_PIXEL (f); | 2316 orig_bg = FRAME_BACKGROUND_PIXEL (f); |
2317 frame_fg = Fcdr (Fassq (Qforeground_color, f->param_alist)); | |
2318 frame_bg = Fcdr (Fassq (Qbackground_color, f->param_alist)); | |
2319 /* frame_fg and frame_bg could be nil if, for example, | |
2320 f->param_alist is nil, e.g. if we are called from | |
2321 Fmake_terminal_frame. */ | |
2322 if (NILP (frame_fg)) | |
2323 frame_fg = build_string (unspecified_fg); | |
2324 if (NILP (frame_bg)) | |
2325 frame_bg = build_string (unspecified_bg); | |
2317 | 2326 |
2318 /* Extract parm names and values into those vectors. */ | 2327 /* Extract parm names and values into those vectors. */ |
2319 i = 0; | 2328 i = 0; |
2320 for (tail = alist; CONSP (tail); tail = Fcdr (tail)) | 2329 for (tail = alist; CONSP (tail); tail = Fcdr (tail)) |
2321 { | 2330 { |
2338 val = values[i]; | 2347 val = values[i]; |
2339 | 2348 |
2340 if (EQ (prop, Qreverse)) | 2349 if (EQ (prop, Qreverse)) |
2341 reverse = EQ (val, Qt); | 2350 reverse = EQ (val, Qt); |
2342 } | 2351 } |
2343 | 2352 |
2344 if (termscript && reverse && !was_reverse) | 2353 need_to_reverse = reverse && !was_reverse; |
2354 if (termscript && need_to_reverse) | |
2345 fprintf (termscript, "<INVERSE-VIDEO>\n"); | 2355 fprintf (termscript, "<INVERSE-VIDEO>\n"); |
2346 | 2356 |
2347 /* Now process the alist elements in reverse of specified order. */ | 2357 /* Now process the alist elements in reverse of specified order. */ |
2348 for (i--; i >= 0; i--) | 2358 for (i--; i >= 0; i--) |
2349 { | 2359 { |
2353 prop = parms[i]; | 2363 prop = parms[i]; |
2354 val = values[i]; | 2364 val = values[i]; |
2355 | 2365 |
2356 if (EQ (prop, Qforeground_color)) | 2366 if (EQ (prop, Qforeground_color)) |
2357 { | 2367 { |
2358 unsigned long new_color = load_color (f, NULL, val, reverse | 2368 unsigned long new_color = load_color (f, NULL, val, need_to_reverse |
2359 ? LFACE_BACKGROUND_INDEX | 2369 ? LFACE_BACKGROUND_INDEX |
2360 : LFACE_FOREGROUND_INDEX); | 2370 : LFACE_FOREGROUND_INDEX); |
2361 if (new_color != FACE_TTY_DEFAULT_COLOR | 2371 if (new_color != FACE_TTY_DEFAULT_COLOR |
2362 && new_color != FACE_TTY_DEFAULT_FG_COLOR | 2372 && new_color != FACE_TTY_DEFAULT_FG_COLOR |
2363 && new_color != FACE_TTY_DEFAULT_BG_COLOR) | 2373 && new_color != FACE_TTY_DEFAULT_BG_COLOR) |
2364 { | 2374 { |
2375 FRAME_FOREGROUND_PIXEL (f) = new_color; | |
2365 /* Make sure the foreground of the default face for this | 2376 /* Make sure the foreground of the default face for this |
2366 frame is changed as well. */ | 2377 frame is changed as well. */ |
2367 XSETFRAME (frame, f); | 2378 XSETFRAME (frame, f); |
2368 if (reverse) | 2379 if (need_to_reverse) |
2369 { | 2380 { |
2370 FRAME_BACKGROUND_PIXEL (f) = new_color; | |
2371 Finternal_set_lisp_face_attribute (Qdefault, QCbackground, | 2381 Finternal_set_lisp_face_attribute (Qdefault, QCbackground, |
2372 val, frame); | 2382 val, frame); |
2383 prop = Qbackground_color; | |
2373 } | 2384 } |
2374 else | 2385 else |
2375 { | 2386 { |
2376 FRAME_FOREGROUND_PIXEL (f) = new_color; | |
2377 Finternal_set_lisp_face_attribute (Qdefault, QCforeground, | 2387 Finternal_set_lisp_face_attribute (Qdefault, QCforeground, |
2378 val, frame); | 2388 val, frame); |
2379 } | 2389 } |
2380 redraw = 1; | 2390 redraw = 1; |
2381 fg_set = 1; | 2391 fg_set = 1; |
2383 fprintf (termscript, "<FGCOLOR %lu>\n", new_color); | 2393 fprintf (termscript, "<FGCOLOR %lu>\n", new_color); |
2384 } | 2394 } |
2385 } | 2395 } |
2386 else if (EQ (prop, Qbackground_color)) | 2396 else if (EQ (prop, Qbackground_color)) |
2387 { | 2397 { |
2388 unsigned long new_color = load_color (f, NULL, val, reverse | 2398 unsigned long new_color = load_color (f, NULL, val, need_to_reverse |
2389 ? LFACE_FOREGROUND_INDEX | 2399 ? LFACE_FOREGROUND_INDEX |
2390 : LFACE_BACKGROUND_INDEX); | 2400 : LFACE_BACKGROUND_INDEX); |
2391 if (new_color != FACE_TTY_DEFAULT_COLOR | 2401 if (new_color != FACE_TTY_DEFAULT_COLOR |
2392 && new_color != FACE_TTY_DEFAULT_FG_COLOR | 2402 && new_color != FACE_TTY_DEFAULT_FG_COLOR |
2393 && new_color != FACE_TTY_DEFAULT_BG_COLOR) | 2403 && new_color != FACE_TTY_DEFAULT_BG_COLOR) |
2394 { | 2404 { |
2405 FRAME_BACKGROUND_PIXEL (f) = new_color; | |
2395 /* Make sure the background of the default face for this | 2406 /* Make sure the background of the default face for this |
2396 frame is changed as well. */ | 2407 frame is changed as well. */ |
2397 XSETFRAME (frame, f); | 2408 XSETFRAME (frame, f); |
2398 if (reverse) | 2409 if (need_to_reverse) |
2399 { | 2410 { |
2400 FRAME_FOREGROUND_PIXEL (f) = new_color; | |
2401 Finternal_set_lisp_face_attribute (Qdefault, QCforeground, | 2411 Finternal_set_lisp_face_attribute (Qdefault, QCforeground, |
2402 val, frame); | 2412 val, frame); |
2413 prop = Qforeground_color; | |
2403 } | 2414 } |
2404 else | 2415 else |
2405 { | 2416 { |
2406 FRAME_BACKGROUND_PIXEL (f) = new_color; | |
2407 Finternal_set_lisp_face_attribute (Qdefault, QCbackground, | 2417 Finternal_set_lisp_face_attribute (Qdefault, QCbackground, |
2408 val, frame); | 2418 val, frame); |
2409 } | 2419 } |
2410 redraw = 1; | 2420 redraw = 1; |
2411 bg_set = 1; | 2421 bg_set = 1; |
2430 store_frame_param (f, prop, val); | 2440 store_frame_param (f, prop, val); |
2431 } | 2441 } |
2432 | 2442 |
2433 /* If they specified "reverse", but not the colors, we need to swap | 2443 /* If they specified "reverse", but not the colors, we need to swap |
2434 the current frame colors. */ | 2444 the current frame colors. */ |
2435 if (reverse && !was_reverse) | 2445 if (need_to_reverse) |
2436 { | 2446 { |
2437 Lisp_Object frame; | 2447 Lisp_Object frame; |
2438 | 2448 |
2439 if (!fg_set) | 2449 if (!fg_set) |
2440 { | 2450 { |
2441 FRAME_BACKGROUND_PIXEL (f) = orig_fg; | |
2442 XSETFRAME (frame, f); | 2451 XSETFRAME (frame, f); |
2443 Finternal_set_lisp_face_attribute (Qdefault, QCbackground, | 2452 Finternal_set_lisp_face_attribute (Qdefault, QCbackground, |
2444 tty_color_name (f, orig_fg), | 2453 tty_color_name (f, orig_fg), |
2445 frame); | 2454 frame); |
2455 store_frame_param (f, Qbackground_color, frame_fg); | |
2446 redraw = 1; | 2456 redraw = 1; |
2447 } | 2457 } |
2448 if (!bg_set) | 2458 if (!bg_set) |
2449 { | 2459 { |
2450 FRAME_FOREGROUND_PIXEL (f) = orig_bg; | |
2451 XSETFRAME (frame, f); | 2460 XSETFRAME (frame, f); |
2452 Finternal_set_lisp_face_attribute (Qdefault, QCforeground, | 2461 Finternal_set_lisp_face_attribute (Qdefault, QCforeground, |
2453 tty_color_name (f, orig_bg), | 2462 tty_color_name (f, orig_bg), |
2454 frame); | 2463 frame); |
2464 store_frame_param (f, Qforeground_color, frame_bg); | |
2455 redraw = 1; | 2465 redraw = 1; |
2456 } | 2466 } |
2457 } | 2467 } |
2458 | 2468 |
2459 if (redraw) | 2469 if (redraw) |