Commit 2d764c78 authored by Eli Zaretskii's avatar Eli Zaretskii

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.
parent f6737cde
No preview for this file type
......@@ -733,6 +733,7 @@ lisp= \
${lispsource}simple.elc \
${lispsource}startup.elc \
${lispsource}subr.elc \
${lispsource}term/tty-colors.elc \
${lispsource}textmodes/fill.elc \
${lispsource}textmodes/page.elc \
${lispsource}textmodes/paragraphs.elc \
......@@ -798,6 +799,7 @@ shortlisp= \
../lisp/simple.elc \
../lisp/startup.elc \
../lisp/subr.elc \
../lisp/term/tty-colors.elc \
../lisp/textmodes/fill.elc \
../lisp/textmodes/page.elc \
../lisp/textmodes/paragraphs.elc \
......
......@@ -5915,7 +5915,15 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\
&& (strcmp (terminal_type, "internal") != 0 || inhibit_window_system)
#endif
&& NILP (Vwindow_system))
call0 (intern ("tty-set-up-initial-frame-faces"));
{
/* For the initial frame, we don't have any way of knowing what
are the foreground and background colors of the terminal. */
struct frame *sf = SELECTED_FRAME();
FRAME_FOREGROUND_PIXEL (sf) = -1;
FRAME_BACKGROUND_PIXEL (sf) = -1;
call0 (intern ("tty-set-up-initial-frame-faces"));
}
}
......
......@@ -173,11 +173,6 @@ Report whether a mouse is present.")
else
return Qnil;
}
/* Function to translate colour names to integers. See lisp/term/pc-win.el
for its definition. */
Lisp_Object Qmsdos_color_translate;
#endif
......@@ -418,8 +413,8 @@ static char *vga_colors[16] = {
that this only performs case-insensitive comparison against the
standard names. For anything more sophisticated, like matching
"gray" with "grey" or translating X color names into their MSDOS
equivalents, call the Lisp function Qmsdos_color_translate (defined
on lisp/term/pc-win.el). */
equivalents, call the Lisp function Qtty_color_desc (defined
on lisp/term/tty-colors.el). */
int
msdos_stdcolor_idx (const char *name)
{
......@@ -433,12 +428,14 @@ msdos_stdcolor_idx (const char *name)
}
/* Given a color index, return its standard name. */
char *
Lisp_Object
msdos_stdcolor_name (int idx)
{
extern Lisp_Object Qunspecified;
if (idx < 0 || idx >= sizeof (vga_colors) / sizeof (vga_colors[0]))
return ""; /* meaning the default */
return vga_colors[idx];
return Qunspecified; /* meaning the default */
return build_string (vga_colors[idx]);
}
/* Support for features that are available when we run in a DOS box
......@@ -533,8 +530,6 @@ syms_of_dosfns ()
defsubr (&Smsdos_mouse_disable);
#ifndef HAVE_X_WINDOWS
defsubr (&Smsdos_mouse_p);
Qmsdos_color_translate = intern ("msdos-color-translate");
staticpro (&Qmsdos_color_translate);
#endif
DEFVAR_INT ("dos-country-code", &dos_country_code,
......
......@@ -36,8 +36,7 @@ extern Lisp_Object Vdos_version;
extern Lisp_Object Vdos_windows_version;
#ifndef HAVE_X_WINDOWS
extern Lisp_Object Vdos_display_scancodes;
extern Lisp_Object Qmsdos_color_translate;
extern int msdos_stdcolor_idx P_ ((const char *));
extern char *msdos_stdcolor_name P_ ((int));
extern Lisp_Object msdos_stdcolor_name P_ ((int));
#endif
......@@ -222,6 +222,8 @@ set_menu_bar_lines (f, value, oldval)
Lisp_Object Vemacs_iconified;
Lisp_Object Vframe_list;
struct x_output tty_display;
extern Lisp_Object Vminibuffer_list;
extern Lisp_Object get_minibuffer ();
extern Lisp_Object Fhandle_switch_frame ();
......@@ -232,6 +234,8 @@ DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
"Return non-nil if OBJECT is a frame.\n\
Value is t for a termcap frame (a character-only terminal),\n\
`x' for an Emacs frame that is really an X window,\n\
`w32' for an Emacs frame that is a window on MS-Windows display,\n\
`mac' for an Emacs frame on a Macintosh display,\n\
`pc' for a direct-write MS-DOS frame.\n\
See also `frame-live-p'.")
(object)
......@@ -545,9 +549,13 @@ make_terminal_frame ()
f->async_visible = 1; /* Don't let visible be cleared later. */
#ifdef MSDOS
f->output_data.x = &the_only_x_display;
f->output_method = output_msdos_raw;
#endif /* MSDOS */
if (!inhibit_window_system
&& (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))
|| XFRAME (selected_frame)->output_method == output_msdos_raw))
f->output_method = output_msdos_raw;
else
f->output_method = output_termcap;
#else
#ifdef macintosh
f->output_data.mac = NewMacWindow(f);
f->output_data.mac->background_pixel = 0xffffff;
......@@ -559,16 +567,15 @@ make_terminal_frame ()
f->auto_raise = 1;
f->auto_lower = 1;
init_frame_faces (f);
#endif /* macintosh */
#else /* !macintosh */
f->output_data.x = &tty_display;
#endif /* !macintosh */
#endif /* MSDOS */
#ifndef MSDOS
#ifndef macintosh
f->output_data.nothing = 1; /* Nonzero means frame isn't deleted. */
#endif
#endif
if (!noninteractive)
init_frame_faces (f);
#endif
return f;
}
......@@ -587,7 +594,8 @@ Note that changing the size of one terminal frame automatically affects all.")
struct frame *sf = SELECTED_FRAME ();
#ifdef MSDOS
if (sf->output_method != output_msdos_raw)
if (sf->output_method != output_msdos_raw
&& sf->output_method != output_termcap)
abort ();
#else /* not MSDOS */
......@@ -1994,23 +2002,20 @@ If FRAME is omitted, return information on the currently selected frame.")
return Qnil;
alist = Fcopy_alist (f->param_alist);
#ifdef MSDOS
if (FRAME_MSDOS_P (f))
if (!FRAME_WINDOW_P (f))
{
int fg = FRAME_FOREGROUND_PIXEL (f);
int bg = FRAME_BACKGROUND_PIXEL (f);
Lisp_Object qreverse = intern ("reverse");
int rv =
!NILP (Fassq (qreverse, alist))
|| !NILP (Fassq (qreverse, Vdefault_frame_alist));
store_in_alist (&alist, intern ("foreground-color"),
build_string (msdos_stdcolor_name (rv ? bg : fg)));
tty_color_name (f, fg));
store_in_alist (&alist, intern ("background-color"),
build_string (msdos_stdcolor_name (rv ? fg : bg)));
tty_color_name (f, bg));
store_in_alist (&alist, intern ("font"),
build_string (FRAME_MSDOS_P (f)
? "ms-dos"
: FRAME_W32_P (f) ? "w32term" : "tty"));
}
store_in_alist (&alist, intern ("font"), build_string ("ms-dos"));
#endif
store_in_alist (&alist, Qname, f->name);
height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f));
store_in_alist (&alist, Qheight, make_number (height));
......
......@@ -55,6 +55,25 @@ enum vertical_scroll_bar_type
vertical_scroll_bar_right
};
#if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(macintosh)
#if !defined(HAVE_X_WINDOWS)
/* A (mostly empty) x_output structure definition for building Emacs
on Unix and GNU/Linux without X support. */
struct x_output
{
PIX_TYPE background_pixel;
PIX_TYPE foreground_pixel;
};
#endif /* ! HAVE_X_WINDOWS */
/* A structure describing a termcap frame display. */
extern struct x_output tty_display;
#endif /* ! MSDOS && ! WINDOWSNT && ! macintosh */
struct frame
{
EMACS_INT size;
......
......@@ -253,7 +253,7 @@ mouse_get_pos (f, insist, bar_window, part, x, y, time)
FOR_EACH_FRAME (tail, frame)
XFRAME (frame)->mouse_moved = 0;
*f = selected_frame;
*f = SELECTED_FRAME();
*bar_window = Qnil;
mouse_get_xy (&ix, &iy);
*time = event_timestamp ();
......@@ -267,7 +267,7 @@ mouse_check_moved ()
int x, y;
mouse_get_xy (&x, &y);
selected_frame->mouse_moved |= (x != mouse_last_x || y != mouse_last_y);
SELECTED_FRAME()->mouse_moved |= (x != mouse_last_x || y != mouse_last_y);
mouse_last_x = x;
mouse_last_y = y;
}
......@@ -344,9 +344,6 @@ static int term_setup_done;
/* Similar to the_only_frame. */
struct x_output the_only_x_display;
/* This is never dereferenced. */
Display *x_current_display;
/* Support for DOS/V (allows Japanese characters to be displayed on
standard, non-Japanese, ATs). Only supported for DJGPP v2 and later. */
......@@ -666,12 +663,13 @@ IT_ring_bell (void)
static void
IT_set_face (int face)
{
struct face *fp = FACE_FROM_ID (selected_frame, face);
struct frame *sf = SELECTED_FRAME();
struct face *fp = FACE_FROM_ID (sf, face);
unsigned long fg, bg;
if (!fp)
{
fp = FACE_FROM_ID (selected_frame, DEFAULT_FACE_ID);
fp = FACE_FROM_ID (sf, DEFAULT_FACE_ID);
/* The default face for the frame should always be realized and
cached. */
if (!fp)
......@@ -688,11 +686,11 @@ IT_set_face (int face)
switches on this mode (and loses the blinking attribute) at
startup. */
if (fg == (unsigned long)-1)
fg = highlight ? FRAME_BACKGROUND_PIXEL (selected_frame)
: FRAME_FOREGROUND_PIXEL (selected_frame);
fg = highlight || fp->tty_reverse_p ? FRAME_BACKGROUND_PIXEL (sf)
: FRAME_FOREGROUND_PIXEL (sf);
if (bg == (unsigned long)-1)
bg = highlight ? FRAME_FOREGROUND_PIXEL (selected_frame)
: FRAME_BACKGROUND_PIXEL (selected_frame);
bg = highlight || fp->tty_reverse_p ? FRAME_FOREGROUND_PIXEL (sf)
: FRAME_BACKGROUND_PIXEL (sf);
if (termscript)
fprintf (termscript, "<FACE %d%s: %d/%d>",
face, highlight ? "H" : "", fp->foreground, fp->background);
......@@ -724,6 +722,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
struct coding_system *coding = (CODING_REQUIRE_ENCODING (&terminal_coding)
? &terminal_coding
: &safe_terminal_coding);
struct frame *sf;
/* Do we need to consider conversion of unibyte characters to
multibyte? */
......@@ -735,6 +734,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
screen_buf = screen_bp = alloca (str_len * 2);
screen_buf_end = screen_buf + str_len * 2;
sf = SELECTED_FRAME();
/* Since faces get cached and uncached behind our back, we can't
rely on their indices in the cache being consistent across
......@@ -783,8 +783,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
{
g = !NILP (Vdos_unsupported_char_glyph)
? Vdos_unsupported_char_glyph
: MAKE_GLYPH (selected_frame, '\177',
GLYPH_FACE (selected_frame, g));
: MAKE_GLYPH (sf, '\177', GLYPH_FACE (sf, g));
ch = FAST_GLYPH_CHAR (g);
}
if (COMPOSITE_CHAR_P (ch))
......@@ -792,7 +791,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
/* If CH is a composite character, we can display
only the first component. */
g = cmpchar_table[COMPOSITE_CHAR_ID (ch)]->glyph[0],
ch = GLYPH_CHAR (selected_frame, g);
ch = GLYPH_CHAR (sf, g);
cf = FAST_GLYPH_FACE (g);
}
......@@ -931,13 +930,13 @@ IT_clear_end_of_line (int first_unused)
int offset = 2 * (new_pos_X + screen_size_X * new_pos_Y);
extern int fatal_error_in_progress;
if (fatal_error_in_progress)
if (new_pos_X >= first_unused || fatal_error_in_progress)
return;
IT_set_face (0);
if (termscript)
fprintf (termscript, "<CLR:EOL>");
i = (j = screen_size_X - new_pos_X) * 2;
i = (j = first_unused - new_pos_X) * 2;
spaces = sp = alloca (i);
while (--j >= 0)
......@@ -950,6 +949,10 @@ IT_clear_end_of_line (int first_unused)
dosmemput (spaces, i, (int)ScreenPrimary + offset);
if (screen_virtual_segment)
dosv_refresh_virtual_screen (offset, i / 2);
/* clear_end_of_line_raw on term.c leaves the cursor at first_unused.
Let's follow their lead, in case someone relies on this. */
new_pos_X = first_unused;
}
static void
......@@ -1028,9 +1031,15 @@ IT_cmgoto (FRAME_PTR f)
{
/* Only set the cursor to where it should be if the display is
already in sync with the window contents. */
int update_cursor_pos = MODIFF == unchanged_modified;
int update_cursor_pos = 1; /* MODIFF == unchanged_modified; */
/* FIXME: This needs to be rewritten for the new redisplay, or
removed. */
#if 0
static int previous_pos_X = -1;
update_cursor_pos = 1; /* temporary!!! */
/* If the display is in sync, forget any previous knowledge about
cursor position. This is primarily for unexpected events like
C-g in the minibuffer. */
......@@ -1066,6 +1075,7 @@ IT_cmgoto (FRAME_PTR f)
update_cursor_pos = 1;
}
}
#endif
if (update_cursor_pos
&& (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y))
......@@ -1088,14 +1098,12 @@ static void
IT_reassert_line_highlight (int new, int vpos)
{
highlight = new;
IT_set_face (0); /* To possibly clear the highlighting. */
}
static void
IT_change_line_highlight (int new_highlight, int y, int vpos, int first_unused_hpos)
{
highlight = new_highlight;
IT_set_face (0); /* To possibly clear the highlighting. */
IT_cursor_to (vpos, 0);
IT_clear_end_of_line (first_unused_hpos);
}
......@@ -1104,8 +1112,6 @@ static void
IT_update_begin (struct frame *foo)
{
highlight = 0;
IT_set_face (0); /* To possibly clear the highlighting. */
screen_face = -1;
}
static void
......@@ -1341,6 +1347,30 @@ IT_set_terminal_window (int foo)
{
}
/* Remember the screen colors of the curent frame, to serve as the
default colors for newly-created frames. */
static int initial_screen_colors[2];
DEFUN ("msdos-remember-default-colors", Fmsdos_remember_default_colors,
Smsdos_remember_default_colors, 1, 1, 0,
"Remember the screen colors of the current frame.")
(frame)
Lisp_Object frame;
{
int reverse;
struct frame *f;
CHECK_FRAME (frame, 0);
f= XFRAME (frame);
reverse = EQ (Fcdr (Fassq (intern ("reverse"), f->param_alist)), Qt);
initial_screen_colors[0]
= reverse ? FRAME_BACKGROUND_PIXEL (f) : FRAME_FOREGROUND_PIXEL (f);
initial_screen_colors[1]
= reverse ? FRAME_FOREGROUND_PIXEL (f) : FRAME_BACKGROUND_PIXEL (f);
}
void
IT_set_frame_parameters (f, alist)
struct frame *f;
......@@ -1348,18 +1378,29 @@ IT_set_frame_parameters (f, alist)
{
Lisp_Object tail;
int length = XINT (Flength (alist));
int i;
int i, j;
Lisp_Object *parms
= (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
Lisp_Object *values
= (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
int redraw;
struct face *dflt = NULL;
if (FRAME_FACE_CACHE (f))
dflt = FACE_FROM_ID (f, DEFAULT_FACE_ID);
redraw = 0;
Lisp_Object qreverse = intern ("reverse");
/* Do we have to reverse the foreground and background colors? */
int reverse = EQ (Fcdr (Fassq (qreverse, f->param_alist)), Qt);
int was_reverse = reverse;
int redraw = 0, fg_set = 0, bg_set = 0;
unsigned long orig_fg;
unsigned long orig_bg;
/* If we are creating a new frame, begin with the original screen colors
used for the initial frame. */
if (alist == Vdefault_frame_alist
&& initial_screen_colors[0] != -1 && initial_screen_colors[1] != -1)
{
FRAME_FOREGROUND_PIXEL (f) = initial_screen_colors[0];
FRAME_BACKGROUND_PIXEL (f) = initial_screen_colors[1];
}
orig_fg = FRAME_FOREGROUND_PIXEL (f);
orig_bg = FRAME_BACKGROUND_PIXEL (f);
/* Extract parm names and values into those vectors. */
i = 0;
......@@ -1374,8 +1415,21 @@ IT_set_frame_parameters (f, alist)
i++;
}
j = i;
/* Now process them in reverse of specified order. */
for (i = 0; i < j; i++)
{
Lisp_Object prop = parms[i];
Lisp_Object val = values[i];
if (EQ (prop, qreverse))
reverse = EQ (val, Qt);
}
if (termscript && reverse && !was_reverse)
fprintf (termscript, "<INVERSE-VIDEO>\n");
/* Now process the alist elements in reverse of specified order. */
for (i--; i >= 0; i--)
{
Lisp_Object prop = parms[i];
......@@ -1383,30 +1437,36 @@ IT_set_frame_parameters (f, alist)
if (EQ (prop, Qforeground_color))
{
unsigned long new_color = load_color (f, NULL, val,
LFACE_FOREGROUND_INDEX);
unsigned long new_color = load_color (f, NULL, val, reverse
? LFACE_BACKGROUND_INDEX
: LFACE_FOREGROUND_INDEX);
if (new_color != ~0)
{
if (!dflt)
abort ();
FRAME_FOREGROUND_PIXEL (f) = new_color;
dflt->foreground = new_color;
if (reverse)
/* FIXME: should the fore-/background of the default
face change here as well? */
FRAME_BACKGROUND_PIXEL (f) = new_color;
else
FRAME_FOREGROUND_PIXEL (f) = new_color;
redraw = 1;
fg_set = 1;
if (termscript)
fprintf (termscript, "<FGCOLOR %lu>\n", new_color);
}
}
else if (EQ (prop, Qbackground_color))
{
unsigned long new_color = load_color (f, NULL, val,
LFACE_BACKGROUND_INDEX);
unsigned long new_color = load_color (f, NULL, val, reverse
? LFACE_FOREGROUND_INDEX
: LFACE_BACKGROUND_INDEX);
if (new_color != ~0)
{
if (!dflt)
abort ();
FRAME_BACKGROUND_PIXEL (f) = new_color;
dflt->background = new_color;
if (reverse)
FRAME_FOREGROUND_PIXEL (f) = new_color;
else
FRAME_BACKGROUND_PIXEL (f) = new_color;
redraw = 1;
bg_set = 1;
if (termscript)
fprintf (termscript, "<BGCOLOR %lu>\n", new_color);
}
......@@ -1417,27 +1477,29 @@ IT_set_frame_parameters (f, alist)
if (termscript)
fprintf (termscript, "<TITLE: %s>\n", XSTRING (val)->data);
}
else if (EQ (prop, intern ("reverse")) && EQ (val, Qt))
{
unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
if (!dflt)
abort ();
FRAME_FOREGROUND_PIXEL (f) = FRAME_BACKGROUND_PIXEL (f); /* FIXME! */
FRAME_BACKGROUND_PIXEL (f) = fg;
dflt->foreground = FRAME_FOREGROUND_PIXEL (f);
dflt->foreground = fg;
if (termscript)
fprintf (termscript, "<INVERSE-VIDEO>\n");
}
store_frame_param (f, prop, val);
}
/* If they specified "reverse", but not the colors, we need to swap
the current frame colors. */
if (reverse && !was_reverse)
{
if (!fg_set)
{
FRAME_BACKGROUND_PIXEL (f) = orig_fg;
redraw = 1;
}
if (!bg_set)
{
FRAME_FOREGROUND_PIXEL (f) = orig_bg;
redraw = 1;
}
}
if (redraw)
{
recompute_basic_faces (f);
if (f == selected_frame)
face_change_count++; /* forces xdisp.c to recompute basic faces */
if (f == SELECTED_FRAME())
redraw_frame (f);
}
}
......@@ -1454,6 +1516,7 @@ internal_terminal_init ()
{
char *term = getenv ("TERM");
char *colors;
struct frame *sf = SELECTED_FRAME();
#ifdef HAVE_X_WINDOWS
if (!inhibit_window_system)
......@@ -1469,16 +1532,20 @@ internal_terminal_init ()
#ifndef HAVE_X_WINDOWS
if (!internal_terminal || inhibit_window_system)
{
selected_frame->output_method = output_termcap;
sf->output_method = output_termcap;
return;
}
Vwindow_system = intern ("pc");
Vwindow_system_version = make_number (1);
sf->output_method = output_msdos_raw;
/* If Emacs was dumped on DOS/V machine, forget the stale VRAM address. */
screen_old_address = 0;
/* Forget the stale screen colors as well. */
initial_screen_colors[0] = initial_screen_colors[1] = -1;
bzero (&the_only_x_display, sizeof the_only_x_display);
the_only_x_display.background_pixel = 7; /* White */
the_only_x_display.foreground_pixel = 0; /* Black */
......@@ -1503,7 +1570,7 @@ internal_terminal_init ()
the_only_x_display.line_height = 1;
the_only_x_display.font = (XFontStruct *)1; /* must *not* be zero */
init_frame_faces (selected_frame);
init_frame_faces (sf);
ring_bell_hook = IT_ring_bell;
insert_glyphs_hook = IT_insert_glyphs;
......@@ -1548,8 +1615,8 @@ dos_get_saved_screen (screen, rows, cols)
void
check_x (void)
{
if (! FRAME_MSDOS_P (selected_frame))
error ("Not running under a windows system");
if (! FRAME_MSDOS_P (SELECTED_FRAME()))
error ("Not running under a window system");
}
#endif
......@@ -2081,7 +2148,7 @@ dos_rawgetc ()
#ifndef HAVE_X_WINDOWS
/* Maybe put the cursor where it should be. */
IT_cmgoto (selected_frame);
IT_cmgoto (SELECTED_FRAME());
#endif
/* The following condition is equivalent to `kbhit ()', except that
......@@ -2294,7 +2361,7 @@ dos_rawgetc ()
event.kind = ascii_keystroke;
event.code = code;
event.modifiers = modifiers;
XSETFRAME (event.frame_or_window, selected_frame);
event.frame_or_window = selected_frame;
event.timestamp = event_timestamp ();
kbd_buffer_store_event (&event);
}
......@@ -2344,7 +2411,7 @@ dos_rawgetc ()
| (press ? down_modifier : up_modifier);
event.x = x;
event.y = y;
XSETFRAME (event.frame_or_window, selected_frame);
event.frame_or_window = selected_frame;
event.timestamp = event_timestamp ();
kbd_buffer_store_event (&event);
}
......@@ -2503,12 +2570,13 @@ IT_menu_display (XMenu *menu, int y, int x, int *faces)
int mx, my;
int enabled, mousehere;
int row, col;
struct frame *sf = SELECTED_FRAME();
width = menu->width;
text = (struct glyph *) xmalloc ((width + 2) * sizeof (struct glyph));
ScreenGetCursor (&row, &col);
mouse_get_xy (&mx, &my);
IT_update_begin (selected_frame);
IT_update_begin (sf);
for (i = 0; i < menu->count; i++)
{
IT_cursor_to (y + i, x);
......@@ -2543,7 +2611,7 @@ IT_menu_display (XMenu *menu, int y, int x, int *faces)
p++;
IT_write_glyphs (text, width + 2);
}
IT_update_end (selected_frame);