diff options
| author | Eli Zaretskii | 2000-10-16 19:16:20 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2000-10-16 19:16:20 +0000 |
| commit | 546701f50f8840be5985f39c355fd6985e63de14 (patch) | |
| tree | 4dbf56eeb29e54396dfb2c14302e7f53e68c8b6f /src | |
| parent | e1d0bbc974d36438b92716b6f487f4f109131642 (diff) | |
| download | emacs-546701f50f8840be5985f39c355fd6985e63de14.tar.gz emacs-546701f50f8840be5985f39c355fd6985e63de14.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/msdos.c | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/src/msdos.c b/src/msdos.c index ca38e8b75d8..1ba98f64a56 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -864,12 +864,13 @@ 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) |
| @@ -878,6 +879,8 @@ IT_set_face (int face) | |||
| 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 |
| @@ -896,8 +899,7 @@ IT_set_face (int face) | |||
| 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 | ||
| @@ -2271,17 +2273,13 @@ DEFUN ("msdos-remember-default-colors", Fmsdos_remember_default_colors, | |||
| 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] | 2281 | initial_screen_colors[0] = FRAME_FOREGROUND_PIXEL (f); |
| 2282 | = reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f); | 2282 | initial_screen_colors[1] = FRAME_BACKGROUND_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 |
| @@ -2300,8 +2298,10 @@ IT_set_frame_parameters (f, alist) | |||
| 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 |
| @@ -2314,6 +2314,15 @@ IT_set_frame_parameters (f, alist) | |||
| 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; |
| @@ -2340,8 +2349,9 @@ IT_set_frame_parameters (f, alist) | |||
| 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. */ |
| @@ -2355,25 +2365,25 @@ IT_set_frame_parameters (f, alist) | |||
| 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 | } |
| @@ -2385,25 +2395,25 @@ IT_set_frame_parameters (f, alist) | |||
| 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 | } |
| @@ -2432,26 +2442,26 @@ IT_set_frame_parameters (f, alist) | |||
| 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 | } |