aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii1999-12-06 16:54:09 +0000
committerEli Zaretskii1999-12-06 16:54:09 +0000
commit2d764c783d0ab96cc246f3bb1dad70f2ef56ce0f (patch)
treefa1366f693555a3ec65273f478ed95babf1bd0a9 /src
parentf6737cde3e786b0e8acea4b613aa42cf49fa204c (diff)
downloademacs-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')
-rw-r--r--src/ChangeLog98
-rw-r--r--src/Makefile.in2
-rw-r--r--src/dispnew.c10
-rw-r--r--src/dosfns.c19
-rw-r--r--src/dosfns.h3
-rw-r--r--src/frame.c45
-rw-r--r--src/frame.h19
-rw-r--r--src/msdos.c229
-rw-r--r--src/msdos.h42
-rw-r--r--src/w32fns.c24
-rw-r--r--src/w32menu.c2
-rw-r--r--src/w32term.h3
-rw-r--r--src/xfaces.c341
-rw-r--r--src/xfns.c48
-rw-r--r--src/xmenu.c2
15 files changed, 535 insertions, 352 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9d8bfaf50fc..01a5e271619 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,101 @@
11999-12-06 Eli Zaretskii <eliz@is.elta.co.il>
2
3 Changes for automatic remapping of X colors on terminal frames:
4
5 * xfaces.c (XColor) [!HAVE_X_WINDOWS]: Provide a typedef for non-X
6 frames.
7 (Vface_tty_color_alist): Remove.
8 (tty_defined_color): New function.
9 (defined_color): Rewrite to support any type of frame.
10 (tty_color_name): New function.
11 (face_color_supported_p, Fface_color_gray_p,
12 Fface_color_supported_p): Support non-X frames.
13 (load_color): Enclose the color name in quotes, in the log
14 messages. Remove DOS-specific version of load_color.
15 (realize_tty_face): Take the supported colors from
16 tty-color-alist. Support translation of X colors to the closest
17 tty color, for both MSDOS and tty frames.
18 [MSDOS]: Don't invert face colors if they were taken from the
19 frame colors.
20 (Fface_register_tty_color, Fface_clear_tty_colors): Remove.
21
22 * frame.h (struct x_output) [!MSDOS, !WINDOWSNT, !HAVE_X_WINDOWS]:
23 Define a mostly empty surrogate.
24 (tty_display): Declare.
25
26 * frame.c (make_terminal_frame) [!macintosh]: Don't use
27 tty_display.
28 (Fframe_parameters): Don't invert colors of non-FRAME_WINDOW_P
29 frames when the frame's param_alist includes 'reverse.
30 (tty_display): Define.
31 (make_terminal_frame) [!MSDOS]: Assign &tty_display to the
32 output_data.x member.
33 (Fframe_parameters): Return foreground and background color names
34 on tty frames as well, in addition to MSDOS frames.
35
36 * msdos.h (DisplayWidth, DisplayHeight): Changes for Lisp_Object
37 selected_frame.
38 (struct x_output): Remove unused members; document who uses each
39 member.
40 (FRAME_PARAM_FACES, FRAME_N_PARAM_FACES, FRAME_DEFAULT_PARAM_FACE,
41 FRAME_MODE_LINE_PARAM_FACE, FRAME_COMPUTED_FACES,
42 FRAME_N_COMPUTED_FACES, FRAME_SIZE_COMPUTED_FACES,
43 FRAME_DEFAULT_FACE, FRAME_MODE_LINE_FACE, unload_color): Remove
44 unused macro definintions.
45
46 * msdos.c (IT_set_frame_parameters): Don't call
47 recompute_basic_faces, the next redisplay will, anyway.
48 (x_current_display): Remove unused variable.
49 Many functions: changes for Lisp_object selected_frame.
50 (IT_set_face): If the tty_reverse_p flag is set for the face,
51 reverse the foreground and background colors.
52 (Fmsdos_remember_default_colors): New function.
53 (syms_of_msdos): Defsubr it.
54 (IT_set_frame_parameters): Use initial_screen_colors[] when
55 creating a new frame. If the frame parameters include 'reverse,
56 swap the foreground and background colors.
57 (internal_terminal_init): Initialize initial_screen_colors to -1.
58 (syms_of_msdos): Add DEFVAR_BOOL for x-stretch-cursor, to shut up
59 cus-start.el.
60
61 * Makefile.in (lisp, shortlisp): Add lisp/term/tty-colors.elc.
62
63 * xfns.c (x_defined_color): Rename from defined_color. All
64 callers changed.
65 (Fxw_color_defined_p): Renamed from Fx_color_defined_p;
66 all callers changed.
67 (Fxw_color_values): Renamed from Fx_color_values; all callers
68 changed.
69 (Fxw_display_color_p): Renamed from Fx_display_color_p; all
70 callers changed.
71 (x_window_to_frame, x_any_window_to_frame,
72 x_non_menubar_window_to_frame, x_menubar_window_to_frame,
73 x_top_window_to_frame): Use !FRAME_X_P instead of
74 f->output_data.nothing.
75 * xterm.h (x_defined_color): Rename from defined_color.
76
77 * w32fns.c (x_window_to_frame): Use FRAME_W32_P instead of
78 f->output_data.nothing.
79 (Fxw_color_defined_p): Renamed from Fx_color_defined_p;
80 all callers changed.
81 (Fxw_color_values): Renamed from Fx_color_values; all callers
82 changed.
83 (Fxw_display_color_p): Renamed from Fx_display_color_p; all
84 callers changed.
85
86 * dispextern.h (tty_color_name): Add prototype.
87
88 * xmenu.c (menubar_id_to_frame): Use FRAME_WINDOW_P instead of
89 f->output_data.nothing.
90 * w32menu.c (menubar_id_to_frame): Likewise.
91 * w32term.h (w32_output): Declare.
92
93 * dosfns.c (Qmsdos_color_translate): Remove.
94 (msdos_stdcolor_name): Now returns a Lisp_Object.
95 * dosfns.h (Qmsdos_color_translate): Remove.
96
97 * s/msdos.h (INTERNAL_TERMINAL): Add entries for color support.
98
11999-12-06 Kenichi Handa <handa@etl.go.jp> 991999-12-06 Kenichi Handa <handa@etl.go.jp>
2 100
3 * fileio.c (decide_coding_unwind): Renamed from 101 * fileio.c (decide_coding_unwind): Renamed from
diff --git a/src/Makefile.in b/src/Makefile.in
index 05d2ddcb147..452fac0c28d 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -733,6 +733,7 @@ lisp= \
733 ${lispsource}simple.elc \ 733 ${lispsource}simple.elc \
734 ${lispsource}startup.elc \ 734 ${lispsource}startup.elc \
735 ${lispsource}subr.elc \ 735 ${lispsource}subr.elc \
736 ${lispsource}term/tty-colors.elc \
736 ${lispsource}textmodes/fill.elc \ 737 ${lispsource}textmodes/fill.elc \
737 ${lispsource}textmodes/page.elc \ 738 ${lispsource}textmodes/page.elc \
738 ${lispsource}textmodes/paragraphs.elc \ 739 ${lispsource}textmodes/paragraphs.elc \
@@ -798,6 +799,7 @@ shortlisp= \
798 ../lisp/simple.elc \ 799 ../lisp/simple.elc \
799 ../lisp/startup.elc \ 800 ../lisp/startup.elc \
800 ../lisp/subr.elc \ 801 ../lisp/subr.elc \
802 ../lisp/term/tty-colors.elc \
801 ../lisp/textmodes/fill.elc \ 803 ../lisp/textmodes/fill.elc \
802 ../lisp/textmodes/page.elc \ 804 ../lisp/textmodes/page.elc \
803 ../lisp/textmodes/paragraphs.elc \ 805 ../lisp/textmodes/paragraphs.elc \
diff --git a/src/dispnew.c b/src/dispnew.c
index 3d5797da6dd..9cdf01e6987 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5915,7 +5915,15 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\
5915 && (strcmp (terminal_type, "internal") != 0 || inhibit_window_system) 5915 && (strcmp (terminal_type, "internal") != 0 || inhibit_window_system)
5916#endif 5916#endif
5917 && NILP (Vwindow_system)) 5917 && NILP (Vwindow_system))
5918 call0 (intern ("tty-set-up-initial-frame-faces")); 5918 {
5919 /* For the initial frame, we don't have any way of knowing what
5920 are the foreground and background colors of the terminal. */
5921 struct frame *sf = SELECTED_FRAME();
5922
5923 FRAME_FOREGROUND_PIXEL (sf) = -1;
5924 FRAME_BACKGROUND_PIXEL (sf) = -1;
5925 call0 (intern ("tty-set-up-initial-frame-faces"));
5926 }
5919} 5927}
5920 5928
5921 5929
diff --git a/src/dosfns.c b/src/dosfns.c
index 59fdd67f934..857d16bd9b2 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -173,11 +173,6 @@ Report whether a mouse is present.")
173 else 173 else
174 return Qnil; 174 return Qnil;
175} 175}
176
177/* Function to translate colour names to integers. See lisp/term/pc-win.el
178 for its definition. */
179
180Lisp_Object Qmsdos_color_translate;
181#endif 176#endif
182 177
183 178
@@ -418,8 +413,8 @@ static char *vga_colors[16] = {
418 that this only performs case-insensitive comparison against the 413 that this only performs case-insensitive comparison against the
419 standard names. For anything more sophisticated, like matching 414 standard names. For anything more sophisticated, like matching
420 "gray" with "grey" or translating X color names into their MSDOS 415 "gray" with "grey" or translating X color names into their MSDOS
421 equivalents, call the Lisp function Qmsdos_color_translate (defined 416 equivalents, call the Lisp function Qtty_color_desc (defined
422 on lisp/term/pc-win.el). */ 417 on lisp/term/tty-colors.el). */
423int 418int
424msdos_stdcolor_idx (const char *name) 419msdos_stdcolor_idx (const char *name)
425{ 420{
@@ -433,12 +428,14 @@ msdos_stdcolor_idx (const char *name)
433} 428}
434 429
435/* Given a color index, return its standard name. */ 430/* Given a color index, return its standard name. */
436char * 431Lisp_Object
437msdos_stdcolor_name (int idx) 432msdos_stdcolor_name (int idx)
438{ 433{
434 extern Lisp_Object Qunspecified;
435
439 if (idx < 0 || idx >= sizeof (vga_colors) / sizeof (vga_colors[0])) 436 if (idx < 0 || idx >= sizeof (vga_colors) / sizeof (vga_colors[0]))
440 return ""; /* meaning the default */ 437 return Qunspecified; /* meaning the default */
441 return vga_colors[idx]; 438 return build_string (vga_colors[idx]);
442} 439}
443 440
444/* Support for features that are available when we run in a DOS box 441/* Support for features that are available when we run in a DOS box
@@ -533,8 +530,6 @@ syms_of_dosfns ()
533 defsubr (&Smsdos_mouse_disable); 530 defsubr (&Smsdos_mouse_disable);
534#ifndef HAVE_X_WINDOWS 531#ifndef HAVE_X_WINDOWS
535 defsubr (&Smsdos_mouse_p); 532 defsubr (&Smsdos_mouse_p);
536 Qmsdos_color_translate = intern ("msdos-color-translate");
537 staticpro (&Qmsdos_color_translate);
538#endif 533#endif
539 534
540 DEFVAR_INT ("dos-country-code", &dos_country_code, 535 DEFVAR_INT ("dos-country-code", &dos_country_code,
diff --git a/src/dosfns.h b/src/dosfns.h
index 61145c0ed21..2ec01bfb655 100644
--- a/src/dosfns.h
+++ b/src/dosfns.h
@@ -36,8 +36,7 @@ extern Lisp_Object Vdos_version;
36extern Lisp_Object Vdos_windows_version; 36extern Lisp_Object Vdos_windows_version;
37#ifndef HAVE_X_WINDOWS 37#ifndef HAVE_X_WINDOWS
38extern Lisp_Object Vdos_display_scancodes; 38extern Lisp_Object Vdos_display_scancodes;
39extern Lisp_Object Qmsdos_color_translate;
40 39
41extern int msdos_stdcolor_idx P_ ((const char *)); 40extern int msdos_stdcolor_idx P_ ((const char *));
42extern char *msdos_stdcolor_name P_ ((int)); 41extern Lisp_Object msdos_stdcolor_name P_ ((int));
43#endif 42#endif
diff --git a/src/frame.c b/src/frame.c
index 8298a01aa17..aaaf03add34 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -222,6 +222,8 @@ set_menu_bar_lines (f, value, oldval)
222Lisp_Object Vemacs_iconified; 222Lisp_Object Vemacs_iconified;
223Lisp_Object Vframe_list; 223Lisp_Object Vframe_list;
224 224
225struct x_output tty_display;
226
225extern Lisp_Object Vminibuffer_list; 227extern Lisp_Object Vminibuffer_list;
226extern Lisp_Object get_minibuffer (); 228extern Lisp_Object get_minibuffer ();
227extern Lisp_Object Fhandle_switch_frame (); 229extern Lisp_Object Fhandle_switch_frame ();
@@ -232,6 +234,8 @@ DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
232 "Return non-nil if OBJECT is a frame.\n\ 234 "Return non-nil if OBJECT is a frame.\n\
233Value is t for a termcap frame (a character-only terminal),\n\ 235Value is t for a termcap frame (a character-only terminal),\n\
234`x' for an Emacs frame that is really an X window,\n\ 236`x' for an Emacs frame that is really an X window,\n\
237`w32' for an Emacs frame that is a window on MS-Windows display,\n\
238`mac' for an Emacs frame on a Macintosh display,\n\
235`pc' for a direct-write MS-DOS frame.\n\ 239`pc' for a direct-write MS-DOS frame.\n\
236See also `frame-live-p'.") 240See also `frame-live-p'.")
237 (object) 241 (object)
@@ -545,9 +549,13 @@ make_terminal_frame ()
545 f->async_visible = 1; /* Don't let visible be cleared later. */ 549 f->async_visible = 1; /* Don't let visible be cleared later. */
546#ifdef MSDOS 550#ifdef MSDOS
547 f->output_data.x = &the_only_x_display; 551 f->output_data.x = &the_only_x_display;
548 f->output_method = output_msdos_raw; 552 if (!inhibit_window_system
549#endif /* MSDOS */ 553 && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))
550 554 || XFRAME (selected_frame)->output_method == output_msdos_raw))
555 f->output_method = output_msdos_raw;
556 else
557 f->output_method = output_termcap;
558#else
551#ifdef macintosh 559#ifdef macintosh
552 f->output_data.mac = NewMacWindow(f); 560 f->output_data.mac = NewMacWindow(f);
553 f->output_data.mac->background_pixel = 0xffffff; 561 f->output_data.mac->background_pixel = 0xffffff;
@@ -559,16 +567,15 @@ make_terminal_frame ()
559 f->auto_raise = 1; 567 f->auto_raise = 1;
560 f->auto_lower = 1; 568 f->auto_lower = 1;
561 init_frame_faces (f); 569 init_frame_faces (f);
562#endif /* macintosh */ 570#else /* !macintosh */
571 f->output_data.x = &tty_display;
572#endif /* !macintosh */
573#endif /* MSDOS */
563 574
564#ifndef MSDOS
565#ifndef macintosh 575#ifndef macintosh
566 f->output_data.nothing = 1; /* Nonzero means frame isn't deleted. */
567#endif
568#endif
569
570 if (!noninteractive) 576 if (!noninteractive)
571 init_frame_faces (f); 577 init_frame_faces (f);
578#endif
572 return f; 579 return f;
573} 580}
574 581
@@ -587,7 +594,8 @@ Note that changing the size of one terminal frame automatically affects all.")
587 struct frame *sf = SELECTED_FRAME (); 594 struct frame *sf = SELECTED_FRAME ();
588 595
589#ifdef MSDOS 596#ifdef MSDOS
590 if (sf->output_method != output_msdos_raw) 597 if (sf->output_method != output_msdos_raw
598 && sf->output_method != output_termcap)
591 abort (); 599 abort ();
592#else /* not MSDOS */ 600#else /* not MSDOS */
593 601
@@ -1994,23 +2002,20 @@ If FRAME is omitted, return information on the currently selected frame.")
1994 return Qnil; 2002 return Qnil;
1995 2003
1996 alist = Fcopy_alist (f->param_alist); 2004 alist = Fcopy_alist (f->param_alist);
1997#ifdef MSDOS 2005 if (!FRAME_WINDOW_P (f))
1998 if (FRAME_MSDOS_P (f))
1999 { 2006 {
2000 int fg = FRAME_FOREGROUND_PIXEL (f); 2007 int fg = FRAME_FOREGROUND_PIXEL (f);
2001 int bg = FRAME_BACKGROUND_PIXEL (f); 2008 int bg = FRAME_BACKGROUND_PIXEL (f);
2002 Lisp_Object qreverse = intern ("reverse");
2003 int rv =
2004 !NILP (Fassq (qreverse, alist))
2005 || !NILP (Fassq (qreverse, Vdefault_frame_alist));
2006 2009
2007 store_in_alist (&alist, intern ("foreground-color"), 2010 store_in_alist (&alist, intern ("foreground-color"),
2008 build_string (msdos_stdcolor_name (rv ? bg : fg))); 2011 tty_color_name (f, fg));
2009 store_in_alist (&alist, intern ("background-color"), 2012 store_in_alist (&alist, intern ("background-color"),
2010 build_string (msdos_stdcolor_name (rv ? fg : bg))); 2013 tty_color_name (f, bg));
2014 store_in_alist (&alist, intern ("font"),
2015 build_string (FRAME_MSDOS_P (f)
2016 ? "ms-dos"
2017 : FRAME_W32_P (f) ? "w32term" : "tty"));
2011 } 2018 }
2012 store_in_alist (&alist, intern ("font"), build_string ("ms-dos"));
2013#endif
2014 store_in_alist (&alist, Qname, f->name); 2019 store_in_alist (&alist, Qname, f->name);
2015 height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f)); 2020 height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f));
2016 store_in_alist (&alist, Qheight, make_number (height)); 2021 store_in_alist (&alist, Qheight, make_number (height));
diff --git a/src/frame.h b/src/frame.h
index 498591106b4..06d1e181b15 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -55,6 +55,25 @@ enum vertical_scroll_bar_type
55 vertical_scroll_bar_right 55 vertical_scroll_bar_right
56}; 56};
57 57
58#if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(macintosh)
59
60#if !defined(HAVE_X_WINDOWS)
61
62/* A (mostly empty) x_output structure definition for building Emacs
63 on Unix and GNU/Linux without X support. */
64struct x_output
65{
66 PIX_TYPE background_pixel;
67 PIX_TYPE foreground_pixel;
68};
69
70#endif /* ! HAVE_X_WINDOWS */
71
72/* A structure describing a termcap frame display. */
73extern struct x_output tty_display;
74
75#endif /* ! MSDOS && ! WINDOWSNT && ! macintosh */
76
58struct frame 77struct frame
59{ 78{
60 EMACS_INT size; 79 EMACS_INT size;
diff --git a/src/msdos.c b/src/msdos.c
index 7b8d74da31f..450d1273c02 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -253,7 +253,7 @@ mouse_get_pos (f, insist, bar_window, part, x, y, time)
253 FOR_EACH_FRAME (tail, frame) 253 FOR_EACH_FRAME (tail, frame)
254 XFRAME (frame)->mouse_moved = 0; 254 XFRAME (frame)->mouse_moved = 0;
255 255
256 *f = selected_frame; 256 *f = SELECTED_FRAME();
257 *bar_window = Qnil; 257 *bar_window = Qnil;
258 mouse_get_xy (&ix, &iy); 258 mouse_get_xy (&ix, &iy);
259 *time = event_timestamp (); 259 *time = event_timestamp ();
@@ -267,7 +267,7 @@ mouse_check_moved ()
267 int x, y; 267 int x, y;
268 268
269 mouse_get_xy (&x, &y); 269 mouse_get_xy (&x, &y);
270 selected_frame->mouse_moved |= (x != mouse_last_x || y != mouse_last_y); 270 SELECTED_FRAME()->mouse_moved |= (x != mouse_last_x || y != mouse_last_y);
271 mouse_last_x = x; 271 mouse_last_x = x;
272 mouse_last_y = y; 272 mouse_last_y = y;
273} 273}
@@ -344,9 +344,6 @@ static int term_setup_done;
344/* Similar to the_only_frame. */ 344/* Similar to the_only_frame. */
345struct x_output the_only_x_display; 345struct x_output the_only_x_display;
346 346
347/* This is never dereferenced. */
348Display *x_current_display;
349
350/* Support for DOS/V (allows Japanese characters to be displayed on 347/* Support for DOS/V (allows Japanese characters to be displayed on
351 standard, non-Japanese, ATs). Only supported for DJGPP v2 and later. */ 348 standard, non-Japanese, ATs). Only supported for DJGPP v2 and later. */
352 349
@@ -666,12 +663,13 @@ IT_ring_bell (void)
666static void 663static void
667IT_set_face (int face) 664IT_set_face (int face)
668{ 665{
669 struct face *fp = FACE_FROM_ID (selected_frame, face); 666 struct frame *sf = SELECTED_FRAME();
667 struct face *fp = FACE_FROM_ID (sf, face);
670 unsigned long fg, bg; 668 unsigned long fg, bg;
671 669
672 if (!fp) 670 if (!fp)
673 { 671 {
674 fp = FACE_FROM_ID (selected_frame, DEFAULT_FACE_ID); 672 fp = FACE_FROM_ID (sf, DEFAULT_FACE_ID);
675 /* The default face for the frame should always be realized and 673 /* The default face for the frame should always be realized and
676 cached. */ 674 cached. */
677 if (!fp) 675 if (!fp)
@@ -688,11 +686,11 @@ IT_set_face (int face)
688 switches on this mode (and loses the blinking attribute) at 686 switches on this mode (and loses the blinking attribute) at
689 startup. */ 687 startup. */
690 if (fg == (unsigned long)-1) 688 if (fg == (unsigned long)-1)
691 fg = highlight ? FRAME_BACKGROUND_PIXEL (selected_frame) 689 fg = highlight || fp->tty_reverse_p ? FRAME_BACKGROUND_PIXEL (sf)
692 : FRAME_FOREGROUND_PIXEL (selected_frame); 690 : FRAME_FOREGROUND_PIXEL (sf);
693 if (bg == (unsigned long)-1) 691 if (bg == (unsigned long)-1)
694 bg = highlight ? FRAME_FOREGROUND_PIXEL (selected_frame) 692 bg = highlight || fp->tty_reverse_p ? FRAME_FOREGROUND_PIXEL (sf)
695 : FRAME_BACKGROUND_PIXEL (selected_frame); 693 : FRAME_BACKGROUND_PIXEL (sf);
696 if (termscript) 694 if (termscript)
697 fprintf (termscript, "<FACE %d%s: %d/%d>", 695 fprintf (termscript, "<FACE %d%s: %d/%d>",
698 face, highlight ? "H" : "", fp->foreground, fp->background); 696 face, highlight ? "H" : "", fp->foreground, fp->background);
@@ -724,6 +722,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
724 struct coding_system *coding = (CODING_REQUIRE_ENCODING (&terminal_coding) 722 struct coding_system *coding = (CODING_REQUIRE_ENCODING (&terminal_coding)
725 ? &terminal_coding 723 ? &terminal_coding
726 : &safe_terminal_coding); 724 : &safe_terminal_coding);
725 struct frame *sf;
727 726
728 /* Do we need to consider conversion of unibyte characters to 727 /* Do we need to consider conversion of unibyte characters to
729 multibyte? */ 728 multibyte? */
@@ -735,6 +734,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
735 734
736 screen_buf = screen_bp = alloca (str_len * 2); 735 screen_buf = screen_bp = alloca (str_len * 2);
737 screen_buf_end = screen_buf + str_len * 2; 736 screen_buf_end = screen_buf + str_len * 2;
737 sf = SELECTED_FRAME();
738 738
739 /* Since faces get cached and uncached behind our back, we can't 739 /* Since faces get cached and uncached behind our back, we can't
740 rely on their indices in the cache being consistent across 740 rely on their indices in the cache being consistent across
@@ -783,8 +783,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
783 { 783 {
784 g = !NILP (Vdos_unsupported_char_glyph) 784 g = !NILP (Vdos_unsupported_char_glyph)
785 ? Vdos_unsupported_char_glyph 785 ? Vdos_unsupported_char_glyph
786 : MAKE_GLYPH (selected_frame, '\177', 786 : MAKE_GLYPH (sf, '\177', GLYPH_FACE (sf, g));
787 GLYPH_FACE (selected_frame, g));
788 ch = FAST_GLYPH_CHAR (g); 787 ch = FAST_GLYPH_CHAR (g);
789 } 788 }
790 if (COMPOSITE_CHAR_P (ch)) 789 if (COMPOSITE_CHAR_P (ch))
@@ -792,7 +791,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
792 /* If CH is a composite character, we can display 791 /* If CH is a composite character, we can display
793 only the first component. */ 792 only the first component. */
794 g = cmpchar_table[COMPOSITE_CHAR_ID (ch)]->glyph[0], 793 g = cmpchar_table[COMPOSITE_CHAR_ID (ch)]->glyph[0],
795 ch = GLYPH_CHAR (selected_frame, g); 794 ch = GLYPH_CHAR (sf, g);
796 cf = FAST_GLYPH_FACE (g); 795 cf = FAST_GLYPH_FACE (g);
797 } 796 }
798 797
@@ -931,13 +930,13 @@ IT_clear_end_of_line (int first_unused)
931 int offset = 2 * (new_pos_X + screen_size_X * new_pos_Y); 930 int offset = 2 * (new_pos_X + screen_size_X * new_pos_Y);
932 extern int fatal_error_in_progress; 931 extern int fatal_error_in_progress;
933 932
934 if (fatal_error_in_progress) 933 if (new_pos_X >= first_unused || fatal_error_in_progress)
935 return; 934 return;
936 935
937 IT_set_face (0); 936 IT_set_face (0);
938 if (termscript) 937 if (termscript)
939 fprintf (termscript, "<CLR:EOL>"); 938 fprintf (termscript, "<CLR:EOL>");
940 i = (j = screen_size_X - new_pos_X) * 2; 939 i = (j = first_unused - new_pos_X) * 2;
941 spaces = sp = alloca (i); 940 spaces = sp = alloca (i);
942 941
943 while (--j >= 0) 942 while (--j >= 0)
@@ -950,6 +949,10 @@ IT_clear_end_of_line (int first_unused)
950 dosmemput (spaces, i, (int)ScreenPrimary + offset); 949 dosmemput (spaces, i, (int)ScreenPrimary + offset);
951 if (screen_virtual_segment) 950 if (screen_virtual_segment)
952 dosv_refresh_virtual_screen (offset, i / 2); 951 dosv_refresh_virtual_screen (offset, i / 2);
952
953 /* clear_end_of_line_raw on term.c leaves the cursor at first_unused.
954 Let's follow their lead, in case someone relies on this. */
955 new_pos_X = first_unused;
953} 956}
954 957
955static void 958static void
@@ -1028,9 +1031,15 @@ IT_cmgoto (FRAME_PTR f)
1028{ 1031{
1029 /* Only set the cursor to where it should be if the display is 1032 /* Only set the cursor to where it should be if the display is
1030 already in sync with the window contents. */ 1033 already in sync with the window contents. */
1031 int update_cursor_pos = MODIFF == unchanged_modified; 1034 int update_cursor_pos = 1; /* MODIFF == unchanged_modified; */
1035
1036 /* FIXME: This needs to be rewritten for the new redisplay, or
1037 removed. */
1038#if 0
1032 static int previous_pos_X = -1; 1039 static int previous_pos_X = -1;
1033 1040
1041 update_cursor_pos = 1; /* temporary!!! */
1042
1034 /* If the display is in sync, forget any previous knowledge about 1043 /* If the display is in sync, forget any previous knowledge about
1035 cursor position. This is primarily for unexpected events like 1044 cursor position. This is primarily for unexpected events like
1036 C-g in the minibuffer. */ 1045 C-g in the minibuffer. */
@@ -1066,6 +1075,7 @@ IT_cmgoto (FRAME_PTR f)
1066 update_cursor_pos = 1; 1075 update_cursor_pos = 1;
1067 } 1076 }
1068 } 1077 }
1078#endif
1069 1079
1070 if (update_cursor_pos 1080 if (update_cursor_pos
1071 && (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y)) 1081 && (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y))
@@ -1088,14 +1098,12 @@ static void
1088IT_reassert_line_highlight (int new, int vpos) 1098IT_reassert_line_highlight (int new, int vpos)
1089{ 1099{
1090 highlight = new; 1100 highlight = new;
1091 IT_set_face (0); /* To possibly clear the highlighting. */
1092} 1101}
1093 1102
1094static void 1103static void
1095IT_change_line_highlight (int new_highlight, int y, int vpos, int first_unused_hpos) 1104IT_change_line_highlight (int new_highlight, int y, int vpos, int first_unused_hpos)
1096{ 1105{
1097 highlight = new_highlight; 1106 highlight = new_highlight;
1098 IT_set_face (0); /* To possibly clear the highlighting. */
1099 IT_cursor_to (vpos, 0); 1107 IT_cursor_to (vpos, 0);
1100 IT_clear_end_of_line (first_unused_hpos); 1108 IT_clear_end_of_line (first_unused_hpos);
1101} 1109}
@@ -1104,8 +1112,6 @@ static void
1104IT_update_begin (struct frame *foo) 1112IT_update_begin (struct frame *foo)
1105{ 1113{
1106 highlight = 0; 1114 highlight = 0;
1107 IT_set_face (0); /* To possibly clear the highlighting. */
1108 screen_face = -1;
1109} 1115}
1110 1116
1111static void 1117static void
@@ -1341,6 +1347,30 @@ IT_set_terminal_window (int foo)
1341{ 1347{
1342} 1348}
1343 1349
1350/* Remember the screen colors of the curent frame, to serve as the
1351 default colors for newly-created frames. */
1352
1353static int initial_screen_colors[2];
1354
1355DEFUN ("msdos-remember-default-colors", Fmsdos_remember_default_colors,
1356 Smsdos_remember_default_colors, 1, 1, 0,
1357 "Remember the screen colors of the current frame.")
1358 (frame)
1359 Lisp_Object frame;
1360{
1361 int reverse;
1362 struct frame *f;
1363
1364 CHECK_FRAME (frame, 0);
1365 f= XFRAME (frame);
1366 reverse = EQ (Fcdr (Fassq (intern ("reverse"), f->param_alist)), Qt);
1367
1368 initial_screen_colors[0]
1369 = reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f);
1370 initial_screen_colors[1]
1371 = reverse ? FRAME_FOREGROUND_PIXEL (f) : FRAME_BACKGROUND_PIXEL (f);
1372}
1373
1344void 1374void
1345IT_set_frame_parameters (f, alist) 1375IT_set_frame_parameters (f, alist)
1346 struct frame *f; 1376 struct frame *f;
@@ -1348,18 +1378,29 @@ IT_set_frame_parameters (f, alist)
1348{ 1378{
1349 Lisp_Object tail; 1379 Lisp_Object tail;
1350 int length = XINT (Flength (alist)); 1380 int length = XINT (Flength (alist));
1351 int i; 1381 int i, j;
1352 Lisp_Object *parms 1382 Lisp_Object *parms
1353 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); 1383 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
1354 Lisp_Object *values 1384 Lisp_Object *values
1355 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); 1385 = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
1356 int redraw; 1386 Lisp_Object qreverse = intern ("reverse");
1357 struct face *dflt = NULL; 1387 /* Do we have to reverse the foreground and background colors? */
1358 1388 int reverse = EQ (Fcdr (Fassq (qreverse, f->param_alist)), Qt);
1359 if (FRAME_FACE_CACHE (f)) 1389 int was_reverse = reverse;
1360 dflt = FACE_FROM_ID (f, DEFAULT_FACE_ID); 1390 int redraw = 0, fg_set = 0, bg_set = 0;
1361 1391 unsigned long orig_fg;
1362 redraw = 0; 1392 unsigned long orig_bg;
1393
1394 /* If we are creating a new frame, begin with the original screen colors
1395 used for the initial frame. */
1396 if (alist == Vdefault_frame_alist
1397 && initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1)
1398 {
1399 FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0];
1400 FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1];
1401 }
1402 orig_fg = FRAME_FOREGROUND_PIXEL (f);
1403 orig_bg = FRAME_BACKGROUND_PIXEL (f);
1363 1404
1364 /* Extract parm names and values into those vectors. */ 1405 /* Extract parm names and values into those vectors. */
1365 i = 0; 1406 i = 0;
@@ -1374,8 +1415,21 @@ IT_set_frame_parameters (f, alist)
1374 i++; 1415 i++;
1375 } 1416 }
1376 1417
1418 j = i;
1377 1419
1378 /* Now process them in reverse of specified order. */ 1420 for (i = 0; i < j; i++)
1421 {
1422 Lisp_Object prop = parms[i];
1423 Lisp_Object val = values[i];
1424
1425 if (EQ (prop, qreverse))
1426 reverse = EQ (val, Qt);
1427 }
1428
1429 if (termscript && reverse && !was_reverse)
1430 fprintf (termscript, "<INVERSE-VIDEO>\n");
1431
1432 /* Now process the alist elements in reverse of specified order. */
1379 for (i--; i >= 0; i--) 1433 for (i--; i >= 0; i--)
1380 { 1434 {
1381 Lisp_Object prop = parms[i]; 1435 Lisp_Object prop = parms[i];
@@ -1383,30 +1437,36 @@ IT_set_frame_parameters (f, alist)
1383 1437
1384 if (EQ (prop, Qforeground_color)) 1438 if (EQ (prop, Qforeground_color))
1385 { 1439 {
1386 unsigned long new_color = load_color (f, NULL, val, 1440 unsigned long new_color = load_color (f, NULL, val, reverse
1387 LFACE_FOREGROUND_INDEX); 1441 ? LFACE_BACKGROUND_INDEX
1442 : LFACE_FOREGROUND_INDEX);
1388 if (new_color != ~0) 1443 if (new_color != ~0)
1389 { 1444 {
1390 if (!dflt) 1445 if (reverse)
1391 abort (); 1446 /* FIXME: should the fore-/background of the default
1392 FRAME_FOREGROUND_PIXEL (f) = new_color; 1447 face change here as well? */
1393 dflt->foreground = new_color; 1448 FRAME_BACKGROUND_PIXEL (f) = new_color;
1449 else
1450 FRAME_FOREGROUND_PIXEL (f) = new_color;
1394 redraw = 1; 1451 redraw = 1;
1452 fg_set = 1;
1395 if (termscript) 1453 if (termscript)
1396 fprintf (termscript, "<FGCOLOR %lu>\n", new_color); 1454 fprintf (termscript, "<FGCOLOR %lu>\n", new_color);
1397 } 1455 }
1398 } 1456 }
1399 else if (EQ (prop, Qbackground_color)) 1457 else if (EQ (prop, Qbackground_color))
1400 { 1458 {
1401 unsigned long new_color = load_color (f, NULL, val, 1459 unsigned long new_color = load_color (f, NULL, val, reverse
1402 LFACE_BACKGROUND_INDEX); 1460 ? LFACE_FOREGROUND_INDEX
1461 : LFACE_BACKGROUND_INDEX);
1403 if (new_color != ~0) 1462 if (new_color != ~0)
1404 { 1463 {
1405 if (!dflt) 1464 if (reverse)
1406 abort (); 1465 FRAME_FOREGROUND_PIXEL (f) = new_color;
1407 FRAME_BACKGROUND_PIXEL (f) = new_color; 1466 else
1408 dflt->background = new_color; 1467 FRAME_BACKGROUND_PIXEL (f) = new_color;
1409 redraw = 1; 1468 redraw = 1;
1469 bg_set = 1;
1410 if (termscript) 1470 if (termscript)
1411 fprintf (termscript, "<BGCOLOR %lu>\n", new_color); 1471 fprintf (termscript, "<BGCOLOR %lu>\n", new_color);
1412 } 1472 }
@@ -1417,27 +1477,29 @@ IT_set_frame_parameters (f, alist)
1417 if (termscript) 1477 if (termscript)
1418 fprintf (termscript, "<TITLE: %s>\n", XSTRING (val)->data); 1478 fprintf (termscript, "<TITLE: %s>\n", XSTRING (val)->data);
1419 } 1479 }
1420 else if (EQ (prop, intern ("reverse")) && EQ (val, Qt))
1421 {
1422 unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
1423
1424 if (!dflt)
1425 abort ();
1426 FRAME_FOREGROUND_PIXEL (f) = FRAME_BACKGROUND_PIXEL (f); /* FIXME! */
1427 FRAME_BACKGROUND_PIXEL (f) = fg;
1428 dflt->foreground = FRAME_FOREGROUND_PIXEL (f);
1429 dflt->foreground = fg;
1430 if (termscript)
1431 fprintf (termscript, "<INVERSE-VIDEO>\n");
1432 }
1433 store_frame_param (f, prop, val); 1480 store_frame_param (f, prop, val);
1481 }
1434 1482
1483 /* If they specified "reverse", but not the colors, we need to swap
1484 the current frame colors. */
1485 if (reverse && !was_reverse)
1486 {
1487 if (!fg_set)
1488 {
1489 FRAME_BACKGROUND_PIXEL (f) = orig_fg;
1490 redraw = 1;
1491 }
1492 if (!bg_set)
1493 {
1494 FRAME_FOREGROUND_PIXEL (f) = orig_bg;
1495 redraw = 1;
1496 }
1435 } 1497 }
1436 1498
1437 if (redraw) 1499 if (redraw)
1438 { 1500 {
1439 recompute_basic_faces (f); 1501 face_change_count++; /* forces xdisp.c to recompute basic faces */
1440 if (f == selected_frame) 1502 if (f == SELECTED_FRAME())
1441 redraw_frame (f); 1503 redraw_frame (f);
1442 } 1504 }
1443} 1505}
@@ -1454,6 +1516,7 @@ internal_terminal_init ()
1454{ 1516{
1455 char *term = getenv ("TERM"); 1517 char *term = getenv ("TERM");
1456 char *colors; 1518 char *colors;
1519 struct frame *sf = SELECTED_FRAME();
1457 1520
1458#ifdef HAVE_X_WINDOWS 1521#ifdef HAVE_X_WINDOWS
1459 if (!inhibit_window_system) 1522 if (!inhibit_window_system)
@@ -1469,16 +1532,20 @@ internal_terminal_init ()
1469#ifndef HAVE_X_WINDOWS 1532#ifndef HAVE_X_WINDOWS
1470 if (!internal_terminal || inhibit_window_system) 1533 if (!internal_terminal || inhibit_window_system)
1471 { 1534 {
1472 selected_frame->output_method = output_termcap; 1535 sf->output_method = output_termcap;
1473 return; 1536 return;
1474 } 1537 }
1475 1538
1476 Vwindow_system = intern ("pc"); 1539 Vwindow_system = intern ("pc");
1477 Vwindow_system_version = make_number (1); 1540 Vwindow_system_version = make_number (1);
1541 sf->output_method = output_msdos_raw;
1478 1542
1479 /* If Emacs was dumped on DOS/V machine, forget the stale VRAM address. */ 1543 /* If Emacs was dumped on DOS/V machine, forget the stale VRAM address. */
1480 screen_old_address = 0; 1544 screen_old_address = 0;
1481 1545
1546 /* Forget the stale screen colors as well. */
1547 initial_screen_colors[0] = initial_screen_colors[1] = -1;
1548
1482 bzero (&the_only_x_display, sizeof the_only_x_display); 1549 bzero (&the_only_x_display, sizeof the_only_x_display);
1483 the_only_x_display.background_pixel = 7; /* White */ 1550 the_only_x_display.background_pixel = 7; /* White */
1484 the_only_x_display.foreground_pixel = 0; /* Black */ 1551 the_only_x_display.foreground_pixel = 0; /* Black */
@@ -1503,7 +1570,7 @@ internal_terminal_init ()
1503 the_only_x_display.line_height = 1; 1570 the_only_x_display.line_height = 1;
1504 the_only_x_display.font = (XFontStruct *)1; /* must *not* be zero */ 1571 the_only_x_display.font = (XFontStruct *)1; /* must *not* be zero */
1505 1572
1506 init_frame_faces (selected_frame); 1573 init_frame_faces (sf);
1507 1574
1508 ring_bell_hook = IT_ring_bell; 1575 ring_bell_hook = IT_ring_bell;
1509 insert_glyphs_hook = IT_insert_glyphs; 1576 insert_glyphs_hook = IT_insert_glyphs;
@@ -1548,8 +1615,8 @@ dos_get_saved_screen (screen, rows, cols)
1548void 1615void
1549check_x (void) 1616check_x (void)
1550{ 1617{
1551 if (! FRAME_MSDOS_P (selected_frame)) 1618 if (! FRAME_MSDOS_P (SELECTED_FRAME()))
1552 error ("Not running under a windows system"); 1619 error ("Not running under a window system");
1553} 1620}
1554 1621
1555#endif 1622#endif
@@ -2081,7 +2148,7 @@ dos_rawgetc ()
2081 2148
2082#ifndef HAVE_X_WINDOWS 2149#ifndef HAVE_X_WINDOWS
2083 /* Maybe put the cursor where it should be. */ 2150 /* Maybe put the cursor where it should be. */
2084 IT_cmgoto (selected_frame); 2151 IT_cmgoto (SELECTED_FRAME());
2085#endif 2152#endif
2086 2153
2087 /* The following condition is equivalent to `kbhit ()', except that 2154 /* The following condition is equivalent to `kbhit ()', except that
@@ -2294,7 +2361,7 @@ dos_rawgetc ()
2294 event.kind = ascii_keystroke; 2361 event.kind = ascii_keystroke;
2295 event.code = code; 2362 event.code = code;
2296 event.modifiers = modifiers; 2363 event.modifiers = modifiers;
2297 XSETFRAME (event.frame_or_window, selected_frame); 2364 event.frame_or_window = selected_frame;
2298 event.timestamp = event_timestamp (); 2365 event.timestamp = event_timestamp ();
2299 kbd_buffer_store_event (&event); 2366 kbd_buffer_store_event (&event);
2300 } 2367 }
@@ -2344,7 +2411,7 @@ dos_rawgetc ()
2344 | (press ? down_modifier : up_modifier); 2411 | (press ? down_modifier : up_modifier);
2345 event.x = x; 2412 event.x = x;
2346 event.y = y; 2413 event.y = y;
2347 XSETFRAME (event.frame_or_window, selected_frame); 2414 event.frame_or_window = selected_frame;
2348 event.timestamp = event_timestamp (); 2415 event.timestamp = event_timestamp ();
2349 kbd_buffer_store_event (&event); 2416 kbd_buffer_store_event (&event);
2350 } 2417 }
@@ -2503,12 +2570,13 @@ IT_menu_display (XMenu *menu, int y, int x, int *faces)
2503 int mx, my; 2570 int mx, my;
2504 int enabled, mousehere; 2571 int enabled, mousehere;
2505 int row, col; 2572 int row, col;
2573 struct frame *sf = SELECTED_FRAME();
2506 2574
2507 width = menu->width; 2575 width = menu->width;
2508 text = (struct glyph *) xmalloc ((width + 2) * sizeof (struct glyph)); 2576 text = (struct glyph *) xmalloc ((width + 2) * sizeof (struct glyph));
2509 ScreenGetCursor (&row, &col); 2577 ScreenGetCursor (&row, &col);
2510 mouse_get_xy (&mx, &my); 2578 mouse_get_xy (&mx, &my);
2511 IT_update_begin (selected_frame); 2579 IT_update_begin (sf);
2512 for (i = 0; i < menu->count; i++) 2580 for (i = 0; i < menu->count; i++)
2513 { 2581 {
2514 IT_cursor_to (y + i, x); 2582 IT_cursor_to (y + i, x);
@@ -2543,7 +2611,7 @@ IT_menu_display (XMenu *menu, int y, int x, int *faces)
2543 p++; 2611 p++;
2544 IT_write_glyphs (text, width + 2); 2612 IT_write_glyphs (text, width + 2);
2545 } 2613 }
2546 IT_update_end (selected_frame); 2614 IT_update_end (sf);
2547 IT_cursor_to (row, col); 2615 IT_cursor_to (row, col);
2548 xfree (text); 2616 xfree (text);
2549} 2617}
@@ -2663,6 +2731,7 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
2663 int leave, result, onepane; 2731 int leave, result, onepane;
2664 int title_faces[4]; /* face to display the menu title */ 2732 int title_faces[4]; /* face to display the menu title */
2665 int buffers_num_deleted = 0; 2733 int buffers_num_deleted = 0;
2734 struct frame *sf = SELECTED_FRAME();
2666 2735
2667 /* Just in case we got here without a mouse present... */ 2736 /* Just in case we got here without a mouse present... */
2668 if (have_mouse <= 0) 2737 if (have_mouse <= 0)
@@ -2681,15 +2750,15 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
2681 state = alloca (menu->panecount * sizeof (struct IT_menu_state)); 2750 state = alloca (menu->panecount * sizeof (struct IT_menu_state));
2682 screensize = screen_size * 2; 2751 screensize = screen_size * 2;
2683 faces[0] 2752 faces[0]
2684 = lookup_derived_face (selected_frame, intern ("msdos-menu-passive-face"), 2753 = lookup_derived_face (sf, intern ("msdos-menu-passive-face"),
2685 CHARSET_ASCII, DEFAULT_FACE_ID); 2754 CHARSET_ASCII, DEFAULT_FACE_ID);
2686 faces[1] 2755 faces[1]
2687 = lookup_derived_face (selected_frame, intern ("msdos-menu-active-face"), 2756 = lookup_derived_face (sf, intern ("msdos-menu-active-face"),
2688 CHARSET_ASCII, DEFAULT_FACE_ID); 2757 CHARSET_ASCII, DEFAULT_FACE_ID);
2689 selectface = intern ("msdos-menu-select-face"); 2758 selectface = intern ("msdos-menu-select-face");
2690 faces[2] = lookup_derived_face (selected_frame, selectface, 2759 faces[2] = lookup_derived_face (sf, selectface,
2691 CHARSET_ASCII, faces[0]); 2760 CHARSET_ASCII, faces[0]);
2692 faces[3] = lookup_derived_face (selected_frame, selectface, 2761 faces[3] = lookup_derived_face (sf, selectface,
2693 CHARSET_ASCII, faces[1]); 2762 CHARSET_ASCII, faces[1]);
2694 2763
2695 /* Make sure the menu title is always displayed with 2764 /* Make sure the menu title is always displayed with
@@ -2740,9 +2809,9 @@ XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
2740 { 2809 {
2741 if (!mouse_visible) mouse_on (); 2810 if (!mouse_visible) mouse_on ();
2742 mouse_check_moved (); 2811 mouse_check_moved ();
2743 if (selected_frame->mouse_moved) 2812 if (sf->mouse_moved)
2744 { 2813 {
2745 selected_frame->mouse_moved = 0; 2814 sf->mouse_moved = 0;
2746 result = XM_IA_SELECT; 2815 result = XM_IA_SELECT;
2747 mouse_get_xy (&x, &y); 2816 mouse_get_xy (&x, &y);
2748 for (i = 0; i < statecount; i++) 2817 for (i = 0; i < statecount; i++)
@@ -2924,8 +2993,8 @@ getdefdir (drive, dst)
2924 *p = '\0'; 2993 *p = '\0';
2925 errno = 0; 2994 errno = 0;
2926 _fixpath (in_path, dst); 2995 _fixpath (in_path, dst);
2927 /* _fixpath can set errno to ENOSYS on non-LFN systems because 2996 /* _fixpath can set errno to ENOSYS on non-LFN systems because
2928 it queries the LFN support, so ignore that error. */ 2997 it queries the LFN support, so ignore that error. */
2929 if ((errno && errno != ENOSYS) || *dst == '\0') 2998 if ((errno && errno != ENOSYS) || *dst == '\0')
2930 return 0; 2999 return 0;
2931 3000
@@ -4075,11 +4144,12 @@ abort ()
4075} 4144}
4076#endif 4145#endif
4077 4146
4078/* The following two are required so that customization feature 4147/* The following variables are required so that cus-start.el won't
4079 won't complain about unbound variables. */ 4148 complain about unbound variables. */
4080#ifndef HAVE_X_WINDOWS 4149#ifndef HAVE_X_WINDOWS
4081/* Search path for bitmap files (xfns.c). */ 4150/* Search path for bitmap files (xfns.c). */
4082Lisp_Object Vx_bitmap_file_path; 4151Lisp_Object Vx_bitmap_file_path;
4152int x_stretch_cursor_p;
4083#endif 4153#endif
4084#ifndef subprocesses 4154#ifndef subprocesses
4085/* Nonzero means delete a process right away if it exits (process.c). */ 4155/* Nonzero means delete a process right away if it exits (process.c). */
@@ -4095,6 +4165,12 @@ syms_of_msdos ()
4095 "List of directories to search for bitmap files for X."); 4165 "List of directories to search for bitmap files for X.");
4096 Vx_bitmap_file_path = decode_env_path ((char *) 0, "."); 4166 Vx_bitmap_file_path = decode_env_path ((char *) 0, ".");
4097 4167
4168 DEFVAR_BOOL ("x-stretch-cursor", &x_stretch_cursor_p,
4169 "*Non-nil means draw block cursor as wide as the glyph under it.\n\
4170For example, if a block cursor is over a tab, it will be drawn as\n\
4171wide as that tab on the display. (No effect on MS-DOS.)");
4172 x_stretch_cursor_p = 0;
4173
4098 /* The following three are from xfns.c: */ 4174 /* The following three are from xfns.c: */
4099 Qbackground_color = intern ("background-color"); 4175 Qbackground_color = intern ("background-color");
4100 staticpro (&Qbackground_color); 4176 staticpro (&Qbackground_color);
@@ -4117,6 +4193,7 @@ nil means don't delete them until `list-processes' is run.");
4117 defsubr (&Srecent_doskeys); 4193 defsubr (&Srecent_doskeys);
4118 defsubr (&Smsdos_long_file_names); 4194 defsubr (&Smsdos_long_file_names);
4119 defsubr (&Smsdos_downcase_filename); 4195 defsubr (&Smsdos_downcase_filename);
4196 defsubr (&Smsdos_remember_default_colors);
4120} 4197}
4121 4198
4122#endif /* MSDOS */ 4199#endif /* MSDOS */
diff --git a/src/msdos.h b/src/msdos.h
index c8ff29c2dd9..87e88dda475 100644
--- a/src/msdos.h
+++ b/src/msdos.h
@@ -58,33 +58,18 @@ typedef int XRectangle;
58/* This is a cut-down version of the one in xterm.h, which see. */ 58/* This is a cut-down version of the one in xterm.h, which see. */
59struct x_output 59struct x_output
60{ 60{
61 int left_pos; 61 int left_pos; /* used in xmenu_show (xmenu.c) */
62 int top_pos; 62 int top_pos; /* ditto */
63 int line_height; 63 int line_height; /* used in x-popup-menu (xmenu.c) */
64 PIX_TYPE background_pixel; 64 PIX_TYPE background_pixel; /* used in xfaces.c and lots of other places */
65 PIX_TYPE foreground_pixel; 65 PIX_TYPE foreground_pixel; /* ditto */
66 XFontStruct *font; 66 XFontStruct *font; /* used in x-popup-menu (xmenu.c) */
67 Window busy_window; 67 Window busy_window; /* currently unused (but maybe some day) */
68 unsigned busy_p : 1; 68 unsigned busy_p : 1; /* ditto */
69 struct face **param_faces;
70 int n_param_faces;
71 struct face **computed_faces;
72 int n_computed_faces;
73 int size_computed_faces;
74}; 69};
75 70
76extern struct x_output the_only_x_display; 71extern struct x_output the_only_x_display;
77extern Display *x_current_display; 72
78
79#define FRAME_PARAM_FACES(f) (the_only_x_display.param_faces)
80#define FRAME_N_PARAM_FACES(f) (the_only_x_display.n_param_faces)
81#define FRAME_DEFAULT_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[0])
82#define FRAME_MODE_LINE_PARAM_FACE(f) (FRAME_PARAM_FACES (f)[1])
83#define FRAME_COMPUTED_FACES(f) (the_only_x_display.computed_faces)
84#define FRAME_N_COMPUTED_FACES(f) (the_only_x_display.n_computed_faces)
85#define FRAME_SIZE_COMPUTED_FACES(f) (the_only_x_display.size_computed_faces)
86#define FRAME_DEFAULT_FACE(f) (the_only_x_display.computed_faces[0])
87#define FRAME_MODE_LINE_FACE(f) (the_only_x_display.computed_faces[1])
88#define FRAME_X_DISPLAY(f) ((Display *) 0) 73#define FRAME_X_DISPLAY(f) ((Display *) 0)
89#define FRAME_FOREGROUND_PIXEL(f) (the_only_x_display.foreground_pixel) 74#define FRAME_FOREGROUND_PIXEL(f) (the_only_x_display.foreground_pixel)
90#define FRAME_BACKGROUND_PIXEL(f) (the_only_x_display.background_pixel) 75#define FRAME_BACKGROUND_PIXEL(f) (the_only_x_display.background_pixel)
@@ -95,10 +80,6 @@ extern Display *x_current_display;
95/* Forward declarations for prototypes. */ 80/* Forward declarations for prototypes. */
96struct frame; 81struct frame;
97struct window; 82struct window;
98#if 0
99extern int face_name_id_number P_ ((struct frame *, Lisp_Object)); /* !!! */
100extern int compute_glyph_face P_ ((struct frame *, int, int)); /* !!! */
101#endif
102 83
103/* From xterm.c; emulated on msdos.c */ 84/* From xterm.c; emulated on msdos.c */
104 85
@@ -116,12 +97,11 @@ extern int x_pixel_width P_ ((struct frame *));
116extern int x_pixel_height P_ ((struct frame *)); 97extern int x_pixel_height P_ ((struct frame *));
117 98
118#define XFreeGC (void) 99#define XFreeGC (void)
119#define unload_color(p1,p2)
120#define x_destroy_bitmap(p1,p2) 100#define x_destroy_bitmap(p1,p2)
121#define load_pixmap(p1,p2,p3,p4) (0) 101#define load_pixmap(p1,p2,p3,p4) (0)
122#define XGetGeometry(p1,p2,p3,p4,p5,p6,p7,p8,p9) 102#define XGetGeometry(p1,p2,p3,p4,p5,p6,p7,p8,p9)
123#define DisplayWidth(p1,p2) (selected_frame->width) 103#define DisplayWidth(p1,p2) (SELECTED_FRAME()->width)
124#define DisplayHeight(p1,p2) (selected_frame->height) 104#define DisplayHeight(p1,p2) (SELECTED_FRAME()->height)
125#define XMenuSetAEQ (void) 105#define XMenuSetAEQ (void)
126#define XMenuSetFreeze (void) 106#define XMenuSetFreeze (void)
127#define XMenuRecompute (void) 107#define XMenuRecompute (void)
diff --git a/src/w32fns.c b/src/w32fns.c
index a3f3e2a0d87..5c8e78c42b7 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -347,8 +347,7 @@ x_window_to_frame (dpyinfo, wdesc)
347 if (!GC_FRAMEP (frame)) 347 if (!GC_FRAMEP (frame))
348 continue; 348 continue;
349 f = XFRAME (frame); 349 f = XFRAME (frame);
350 if (f->output_data.nothing == 1 350 if (!FRAME_W32_P (f) || FRAME_W32_DISPLAY_INFO (f) != dpyinfo)
351 || FRAME_W32_DISPLAY_INFO (f) != dpyinfo)
352 continue; 351 continue;
353 if (FRAME_W32_WINDOW (f) == wdesc) 352 if (FRAME_W32_WINDOW (f) == wdesc)
354 return f; 353 return f;
@@ -6449,9 +6448,8 @@ Lisp_Object w32_find_bdf_fonts_in_dir( Lisp_Object directory )
6449} 6448}
6450 6449
6451 6450
6452DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0, 6451DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
6453 "Return non-nil if color COLOR is supported on frame FRAME.\n\ 6452 "Internal function called by `color-defined-p', which see.")
6454If FRAME is omitted or nil, use the selected frame.")
6455 (color, frame) 6453 (color, frame)
6456 Lisp_Object color, frame; 6454 Lisp_Object color, frame;
6457{ 6455{
@@ -6466,12 +6464,8 @@ If FRAME is omitted or nil, use the selected frame.")
6466 return Qnil; 6464 return Qnil;
6467} 6465}
6468 6466
6469DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 2, 0, 6467DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
6470 "Return a description of the color named COLOR on frame FRAME.\n\ 6468 "Internal function called by `color-values', which see.")
6471The value is a list of integer RGB values--(RED GREEN BLUE).\n\
6472These values appear to range from 0 to 65280 or 65535, depending\n\
6473on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
6474If FRAME is omitted or nil, use the selected frame.")
6475 (color, frame) 6469 (color, frame)
6476 Lisp_Object color, frame; 6470 Lisp_Object color, frame;
6477{ 6471{
@@ -6493,7 +6487,7 @@ If FRAME is omitted or nil, use the selected frame.")
6493 return Qnil; 6487 return Qnil;
6494} 6488}
6495 6489
6496DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 1, 0, 6490DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
6497 "Return t if the X display supports color.\n\ 6491 "Return t if the X display supports color.\n\
6498The optional argument DISPLAY specifies which display to ask about.\n\ 6492The optional argument DISPLAY specifies which display to ask about.\n\
6499DISPLAY should be either a frame or a display name (a string).\n\ 6493DISPLAY should be either a frame or a display name (a string).\n\
@@ -7595,10 +7589,10 @@ only be necessary if the default setting causes problems.");
7595 7589
7596 defsubr (&Sx_get_resource); 7590 defsubr (&Sx_get_resource);
7597 defsubr (&Sx_list_fonts); 7591 defsubr (&Sx_list_fonts);
7598 defsubr (&Sx_display_color_p); 7592 defsubr (&Sxw_display_color_p);
7599 defsubr (&Sx_display_grayscale_p); 7593 defsubr (&Sx_display_grayscale_p);
7600 defsubr (&Sx_color_defined_p); 7594 defsubr (&Sxw_color_defined_p);
7601 defsubr (&Sx_color_values); 7595 defsubr (&Sxw_color_values);
7602 defsubr (&Sx_server_max_request_size); 7596 defsubr (&Sx_server_max_request_size);
7603 defsubr (&Sx_server_vendor); 7597 defsubr (&Sx_server_vendor);
7604 defsubr (&Sx_server_version); 7598 defsubr (&Sx_server_version);
diff --git a/src/w32menu.c b/src/w32menu.c
index c93c589f07d..5f0d0eb83da 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -219,7 +219,7 @@ menubar_id_to_frame (HMENU menu)
219 if (!GC_FRAMEP (frame)) 219 if (!GC_FRAMEP (frame))
220 continue; 220 continue;
221 f = XFRAME (frame); 221 f = XFRAME (frame);
222 if (f->output_data.nothing == 1) 222 if (!FRAME_W32_P (f))
223 continue; 223 continue;
224 if (f->output_data.w32->menubar_widget == menu) 224 if (f->output_data.w32->menubar_widget == menu)
225 return f; 225 return f;
diff --git a/src/w32term.h b/src/w32term.h
index 3ee2199d1d8..f762bd3afcc 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -343,6 +343,9 @@ struct w32_output
343 volatile char pending_menu_activation; 343 volatile char pending_menu_activation;
344}; 344};
345 345
346/* A (mostly empty) structure describing a w32 terminal frame display. */
347extern struct w32_output w32term_display;
348
346/* Get at the computed faces of an X window frame. */ 349/* Get at the computed faces of an X window frame. */
347#define FRAME_PARAM_FACES(f) ((f)->output_data.w32->param_faces) 350#define FRAME_PARAM_FACES(f) ((f)->output_data.w32->param_faces)
348#define FRAME_N_PARAM_FACES(f) ((f)->output_data.w32->n_param_faces) 351#define FRAME_N_PARAM_FACES(f) ((f)->output_data.w32->n_param_faces)
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
260typedef 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
260Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline; 270Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline;
@@ -368,10 +378,8 @@ static int next_lface_id;
368static Lisp_Object *lface_id_to_name; 378static Lisp_Object *lface_id_to_name;
369static int lface_id_to_name_size; 379static 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. */ 382Lisp_Object Qtty_color_desc, Qtty_color_by_index;
373
374Lisp_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. */
1079int
1080tty_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. */
1125int
1126defined_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
1156Lisp_Object
1157tty_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, &not_used, 0));
1234}
1119 1235
1120 1236
1121DEFUN ("face-color-gray-p", Fface_color_gray_p, Sface_color_gray_p, 1, 2, 0, 1237DEFUN ("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
1378unsigned long
1379load_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
2716static int 2771static int
2717set_lface_from_font_name (f, lface, font_name, force_p, may_fail_p) 2772set_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
6094DEFUN ("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\
6097COLOR 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
6115DEFUN ("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
6124DEFUN ("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}
diff --git a/src/xfns.c b/src/xfns.c
index 813b39a162e..59fa8e0b536 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -350,7 +350,7 @@ x_window_to_frame (dpyinfo, wdesc)
350 if (!GC_FRAMEP (frame)) 350 if (!GC_FRAMEP (frame))
351 continue; 351 continue;
352 f = XFRAME (frame); 352 f = XFRAME (frame);
353 if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo) 353 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
354 continue; 354 continue;
355#ifdef USE_X_TOOLKIT 355#ifdef USE_X_TOOLKIT
356 if ((f->output_data.x->edit_widget 356 if ((f->output_data.x->edit_widget
@@ -388,7 +388,7 @@ x_any_window_to_frame (dpyinfo, wdesc)
388 if (!GC_FRAMEP (frame)) 388 if (!GC_FRAMEP (frame))
389 continue; 389 continue;
390 f = XFRAME (frame); 390 f = XFRAME (frame);
391 if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo) 391 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
392 continue; 392 continue;
393 x = f->output_data.x; 393 x = f->output_data.x;
394 /* This frame matches if the window is any of its widgets. */ 394 /* This frame matches if the window is any of its widgets. */
@@ -426,7 +426,7 @@ x_non_menubar_window_to_frame (dpyinfo, wdesc)
426 if (!GC_FRAMEP (frame)) 426 if (!GC_FRAMEP (frame))
427 continue; 427 continue;
428 f = XFRAME (frame); 428 f = XFRAME (frame);
429 if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo) 429 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
430 continue; 430 continue;
431 x = f->output_data.x; 431 x = f->output_data.x;
432 /* This frame matches if the window is any of its widgets. */ 432 /* This frame matches if the window is any of its widgets. */
@@ -461,7 +461,7 @@ x_menubar_window_to_frame (dpyinfo, wdesc)
461 if (!GC_FRAMEP (frame)) 461 if (!GC_FRAMEP (frame))
462 continue; 462 continue;
463 f = XFRAME (frame); 463 f = XFRAME (frame);
464 if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo) 464 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
465 continue; 465 continue;
466 x = f->output_data.x; 466 x = f->output_data.x;
467 /* Match if the window is this frame's menubar. */ 467 /* Match if the window is this frame's menubar. */
@@ -490,7 +490,7 @@ x_top_window_to_frame (dpyinfo, wdesc)
490 if (!GC_FRAMEP (frame)) 490 if (!GC_FRAMEP (frame))
491 continue; 491 continue;
492 f = XFRAME (frame); 492 f = XFRAME (frame);
493 if (f->output_data.nothing == 1 || FRAME_X_DISPLAY_INFO (f) != dpyinfo) 493 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
494 continue; 494 continue;
495 x = f->output_data.x; 495 x = f->output_data.x;
496 496
@@ -1230,7 +1230,7 @@ gamma_correct (f, color)
1230 If ALLOC is nonzero, allocate a new colormap cell. */ 1230 If ALLOC is nonzero, allocate a new colormap cell. */
1231 1231
1232int 1232int
1233defined_color (f, color, color_def, alloc) 1233x_defined_color (f, color, color_def, alloc)
1234 FRAME_PTR f; 1234 FRAME_PTR f;
1235 char *color; 1235 char *color;
1236 XColor *color_def; 1236 XColor *color_def;
@@ -1341,9 +1341,9 @@ x_decode_color (f, arg, def)
1341 if (FRAME_X_DISPLAY_INFO (f)->n_planes == 1) 1341 if (FRAME_X_DISPLAY_INFO (f)->n_planes == 1)
1342 return def; 1342 return def;
1343 1343
1344 /* defined_color is responsible for coping with failures 1344 /* x_defined_color is responsible for coping with failures
1345 by looking for a near-miss. */ 1345 by looking for a near-miss. */
1346 if (defined_color (f, XSTRING (arg)->data, &cdef, 1)) 1346 if (x_defined_color (f, XSTRING (arg)->data, &cdef, 1))
1347 return cdef.pixel; 1347 return cdef.pixel;
1348 1348
1349 Fsignal (Qerror, Fcons (build_string ("undefined color"), 1349 Fsignal (Qerror, Fcons (build_string ("undefined color"),
@@ -3908,9 +3908,8 @@ x_get_focus_frame (frame)
3908} 3908}
3909 3909
3910 3910
3911DEFUN ("x-color-defined-p", Fx_color_defined_p, Sx_color_defined_p, 1, 2, 0, 3911DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
3912 "Return non-nil if color COLOR is supported on frame FRAME.\n\ 3912 "Internal function called by `color-defined-p', which see.")
3913If FRAME is omitted or nil, use the selected frame.")
3914 (color, frame) 3913 (color, frame)
3915 Lisp_Object color, frame; 3914 Lisp_Object color, frame;
3916{ 3915{
@@ -3919,18 +3918,14 @@ If FRAME is omitted or nil, use the selected frame.")
3919 3918
3920 CHECK_STRING (color, 1); 3919 CHECK_STRING (color, 1);
3921 3920
3922 if (defined_color (f, XSTRING (color)->data, &foo, 0)) 3921 if (x_defined_color (f, XSTRING (color)->data, &foo, 0))
3923 return Qt; 3922 return Qt;
3924 else 3923 else
3925 return Qnil; 3924 return Qnil;
3926} 3925}
3927 3926
3928DEFUN ("x-color-values", Fx_color_values, Sx_color_values, 1, 2, 0, 3927DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
3929 "Return a description of the color named COLOR on frame FRAME.\n\ 3928 "Internal function called by `color-values', which see.")
3930The value is a list of integer RGB values--(RED GREEN BLUE).\n\
3931These values appear to range from 0 to 65280 or 65535, depending\n\
3932on the system; white is (65280 65280 65280) or (65535 65535 65535).\n\
3933If FRAME is omitted or nil, use the selected frame.")
3934 (color, frame) 3929 (color, frame)
3935 Lisp_Object color, frame; 3930 Lisp_Object color, frame;
3936{ 3931{
@@ -3939,7 +3934,7 @@ If FRAME is omitted or nil, use the selected frame.")
3939 3934
3940 CHECK_STRING (color, 1); 3935 CHECK_STRING (color, 1);
3941 3936
3942 if (defined_color (f, XSTRING (color)->data, &foo, 0)) 3937 if (x_defined_color (f, XSTRING (color)->data, &foo, 0))
3943 { 3938 {
3944 Lisp_Object rgb[3]; 3939 Lisp_Object rgb[3];
3945 3940
@@ -3952,11 +3947,8 @@ If FRAME is omitted or nil, use the selected frame.")
3952 return Qnil; 3947 return Qnil;
3953} 3948}
3954 3949
3955DEFUN ("x-display-color-p", Fx_display_color_p, Sx_display_color_p, 0, 1, 0, 3950DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
3956 "Return t if the X display supports color.\n\ 3951 "Internal function called by `display-color-p', which see.")
3957The optional argument DISPLAY specifies which display to ask about.\n\
3958DISPLAY should be either a frame or a display name (a string).\n\
3959If omitted or nil, that stands for the selected frame's display.")
3960 (display) 3952 (display)
3961 Lisp_Object display; 3953 Lisp_Object display;
3962{ 3954{
@@ -5878,7 +5870,7 @@ x_alloc_image_color (f, img, color_name, dflt)
5878 5870
5879 xassert (STRINGP (color_name)); 5871 xassert (STRINGP (color_name));
5880 5872
5881 if (defined_color (f, XSTRING (color_name)->data, &color, 1)) 5873 if (x_defined_color (f, XSTRING (color_name)->data, &color, 1))
5882 { 5874 {
5883 /* This isn't called frequently so we get away with simply 5875 /* This isn't called frequently so we get away with simply
5884 reallocating the color vector to the needed size, here. */ 5876 reallocating the color vector to the needed size, here. */
@@ -10333,10 +10325,10 @@ Each element of the list is a symbol for a supported image type.");
10333 defsubr (&Sx_contour_region); 10325 defsubr (&Sx_contour_region);
10334 defsubr (&Sx_uncontour_region); 10326 defsubr (&Sx_uncontour_region);
10335#endif 10327#endif
10336 defsubr (&Sx_display_color_p); 10328 defsubr (&Sxw_display_color_p);
10337 defsubr (&Sx_display_grayscale_p); 10329 defsubr (&Sx_display_grayscale_p);
10338 defsubr (&Sx_color_defined_p); 10330 defsubr (&Sxw_color_defined_p);
10339 defsubr (&Sx_color_values); 10331 defsubr (&Sxw_color_values);
10340 defsubr (&Sx_server_max_request_size); 10332 defsubr (&Sx_server_max_request_size);
10341 defsubr (&Sx_server_vendor); 10333 defsubr (&Sx_server_vendor);
10342 defsubr (&Sx_server_version); 10334 defsubr (&Sx_server_version);
diff --git a/src/xmenu.c b/src/xmenu.c
index a9bda2154d3..fd42d5f8a4a 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -215,7 +215,7 @@ menubar_id_to_frame (id)
215 if (!GC_FRAMEP (frame)) 215 if (!GC_FRAMEP (frame))
216 continue; 216 continue;
217 f = XFRAME (frame); 217 f = XFRAME (frame);
218 if (f->output_data.nothing == 1) 218 if (!FRAME_WINDOW_P (f))
219 continue; 219 continue;
220 if (f->output_data.x->id == id) 220 if (f->output_data.x->id == id)
221 return f; 221 return f;