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= \ ...@@ -733,6 +733,7 @@ lisp= \
${lispsource}simple.elc \ ${lispsource}simple.elc \
${lispsource}startup.elc \ ${lispsource}startup.elc \
${lispsource}subr.elc \ ${lispsource}subr.elc \
${lispsource}term/tty-colors.elc \
${lispsource}textmodes/fill.elc \ ${lispsource}textmodes/fill.elc \
${lispsource}textmodes/page.elc \ ${lispsource}textmodes/page.elc \
${lispsource}textmodes/paragraphs.elc \ ${lispsource}textmodes/paragraphs.elc \
...@@ -798,6 +799,7 @@ shortlisp= \ ...@@ -798,6 +799,7 @@ shortlisp= \
../lisp/simple.elc \ ../lisp/simple.elc \
../lisp/startup.elc \ ../lisp/startup.elc \
../lisp/subr.elc \ ../lisp/subr.elc \
../lisp/term/tty-colors.elc \
../lisp/textmodes/fill.elc \ ../lisp/textmodes/fill.elc \
../lisp/textmodes/page.elc \ ../lisp/textmodes/page.elc \
../lisp/textmodes/paragraphs.elc \ ../lisp/textmodes/paragraphs.elc \
......
...@@ -5915,7 +5915,15 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\ ...@@ -5915,7 +5915,15 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\
&& (strcmp (terminal_type, "internal") != 0 || inhibit_window_system) && (strcmp (terminal_type, "internal") != 0 || inhibit_window_system)
#endif #endif
&& NILP (Vwindow_system)) && 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.") ...@@ -173,11 +173,6 @@ Report whether a mouse is present.")
else else
return Qnil; return Qnil;
} }
/* Function to translate colour names to integers. See lisp/term/pc-win.el
for its definition. */
Lisp_Object Qmsdos_color_translate;
#endif #endif
...@@ -418,8 +413,8 @@ static char *vga_colors[16] = { ...@@ -418,8 +413,8 @@ static char *vga_colors[16] = {
that this only performs case-insensitive comparison against the that this only performs case-insensitive comparison against the
standard names. For anything more sophisticated, like matching standard names. For anything more sophisticated, like matching
"gray" with "grey" or translating X color names into their MSDOS "gray" with "grey" or translating X color names into their MSDOS
equivalents, call the Lisp function Qmsdos_color_translate (defined equivalents, call the Lisp function Qtty_color_desc (defined
on lisp/term/pc-win.el). */ on lisp/term/tty-colors.el). */
int int
msdos_stdcolor_idx (const char *name) msdos_stdcolor_idx (const char *name)
{ {
...@@ -433,12 +428,14 @@ msdos_stdcolor_idx (const char *name) ...@@ -433,12 +428,14 @@ msdos_stdcolor_idx (const char *name)
} }
/* Given a color index, return its standard name. */ /* Given a color index, return its standard name. */
char * Lisp_Object
msdos_stdcolor_name (int idx) msdos_stdcolor_name (int idx)
{ {
extern Lisp_Object Qunspecified;
if (idx < 0 || idx >= sizeof (vga_colors) / sizeof (vga_colors[0])) if (idx < 0 || idx >= sizeof (vga_colors) / sizeof (vga_colors[0]))
return ""; /* meaning the default */ return Qunspecified; /* meaning the default */
return vga_colors[idx]; return build_string (vga_colors[idx]);
} }
/* Support for features that are available when we run in a DOS box /* Support for features that are available when we run in a DOS box
...@@ -533,8 +530,6 @@ syms_of_dosfns () ...@@ -533,8 +530,6 @@ syms_of_dosfns ()
defsubr (&Smsdos_mouse_disable); defsubr (&Smsdos_mouse_disable);
#ifndef HAVE_X_WINDOWS #ifndef HAVE_X_WINDOWS
defsubr (&Smsdos_mouse_p); defsubr (&Smsdos_mouse_p);
Qmsdos_color_translate = intern ("msdos-color-translate");
staticpro (&Qmsdos_color_translate);
#endif #endif
DEFVAR_INT ("dos-country-code", &dos_country_code, DEFVAR_INT ("dos-country-code", &dos_country_code,
......
...@@ -36,8 +36,7 @@ extern Lisp_Object Vdos_version; ...@@ -36,8 +36,7 @@ extern Lisp_Object Vdos_version;
extern Lisp_Object Vdos_windows_version; extern Lisp_Object Vdos_windows_version;
#ifndef HAVE_X_WINDOWS #ifndef HAVE_X_WINDOWS
extern Lisp_Object Vdos_display_scancodes; extern Lisp_Object Vdos_display_scancodes;
extern Lisp_Object Qmsdos_color_translate;
extern int msdos_stdcolor_idx P_ ((const char *)); extern int msdos_stdcolor_idx P_ ((const char *));
extern char *msdos_stdcolor_name P_ ((int)); extern Lisp_Object msdos_stdcolor_name P_ ((int));
#endif #endif
...@@ -222,6 +222,8 @@ set_menu_bar_lines (f, value, oldval) ...@@ -222,6 +222,8 @@ set_menu_bar_lines (f, value, oldval)
Lisp_Object Vemacs_iconified; Lisp_Object Vemacs_iconified;
Lisp_Object Vframe_list; Lisp_Object Vframe_list;
struct x_output tty_display;
extern Lisp_Object Vminibuffer_list; extern Lisp_Object Vminibuffer_list;
extern Lisp_Object get_minibuffer (); extern Lisp_Object get_minibuffer ();
extern Lisp_Object Fhandle_switch_frame (); extern Lisp_Object Fhandle_switch_frame ();
...@@ -232,6 +234,8 @@ DEFUN ("framep", Fframep, Sframep, 1, 1, 0, ...@@ -232,6 +234,8 @@ DEFUN ("framep", Fframep, Sframep, 1, 1, 0,
"Return non-nil if OBJECT is a frame.\n\ "Return non-nil if OBJECT is a frame.\n\
Value is t for a termcap frame (a character-only terminal),\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\ `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\ `pc' for a direct-write MS-DOS frame.\n\
See also `frame-live-p'.") See also `frame-live-p'.")
(object) (object)
...@@ -545,9 +549,13 @@ make_terminal_frame () ...@@ -545,9 +549,13 @@ make_terminal_frame ()
f->async_visible = 1; /* Don't let visible be cleared later. */ f->async_visible = 1; /* Don't let visible be cleared later. */
#ifdef MSDOS #ifdef MSDOS
f->output_data.x = &the_only_x_display; f->output_data.x = &the_only_x_display;
f->output_method = output_msdos_raw; if (!inhibit_window_system
#endif /* MSDOS */ && (!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 #ifdef macintosh
f->output_data.mac = NewMacWindow(f); f->output_data.mac = NewMacWindow(f);
f->output_data.mac->background_pixel = 0xffffff; f->output_data.mac->background_pixel = 0xffffff;
...@@ -559,16 +567,15 @@ make_terminal_frame () ...@@ -559,16 +567,15 @@ make_terminal_frame ()
f->auto_raise = 1; f->auto_raise = 1;
f->auto_lower = 1; f->auto_lower = 1;
init_frame_faces (f); init_frame_faces (f);
#endif /* macintosh */ #else /* !macintosh */
f->output_data.x = &tty_display;
#endif /* !macintosh */
#endif /* MSDOS */
#ifndef MSDOS
#ifndef macintosh #ifndef macintosh
f->output_data.nothing = 1; /* Nonzero means frame isn't deleted. */
#endif
#endif
if (!noninteractive) if (!noninteractive)
init_frame_faces (f); init_frame_faces (f);
#endif
return f; return f;
} }
...@@ -587,7 +594,8 @@ Note that changing the size of one terminal frame automatically affects all.") ...@@ -587,7 +594,8 @@ Note that changing the size of one terminal frame automatically affects all.")
struct frame *sf = SELECTED_FRAME (); struct frame *sf = SELECTED_FRAME ();
#ifdef MSDOS #ifdef MSDOS
if (sf->output_method != output_msdos_raw) if (sf->output_method != output_msdos_raw
&& sf->output_method != output_termcap)
abort (); abort ();
#else /* not MSDOS */ #else /* not MSDOS */
...@@ -1994,23 +2002,20 @@ If FRAME is omitted, return information on the currently selected frame.") ...@@ -1994,23 +2002,20 @@ If FRAME is omitted, return information on the currently selected frame.")
return Qnil; return Qnil;
alist = Fcopy_alist (f->param_alist); alist = Fcopy_alist (f->param_alist);
#ifdef MSDOS if (!FRAME_WINDOW_P (f))
if (FRAME_MSDOS_P (f))
{ {
int fg = FRAME_FOREGROUND_PIXEL (f); int fg = FRAME_FOREGROUND_PIXEL (f);
int bg = FRAME_BACKGROUND_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"), 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"), 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); store_in_alist (&alist, Qname, f->name);
height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f)); height = (FRAME_NEW_HEIGHT (f) ? FRAME_NEW_HEIGHT (f) : FRAME_HEIGHT (f));
store_in_alist (&alist, Qheight, make_number (height)); store_in_alist (&alist, Qheight, make_number (height));
......
...@@ -55,6 +55,25 @@ enum vertical_scroll_bar_type ...@@ -55,6 +55,25 @@ enum vertical_scroll_bar_type
vertical_scroll_bar_right 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 struct frame
{ {
EMACS_INT size; EMACS_INT size;
......
...@@ -253,7 +253,7 @@ mouse_get_pos (f, insist, bar_window, part, x, y, time) ...@@ -253,7 +253,7 @@ mouse_get_pos (f, insist, bar_window, part, x, y, time)
FOR_EACH_FRAME (tail, frame) FOR_EACH_FRAME (tail, frame)
XFRAME (frame)->mouse_moved = 0; XFRAME (frame)->mouse_moved = 0;
*f = selected_frame; *f = SELECTED_FRAME();
*bar_window = Qnil; *bar_window = Qnil;
mouse_get_xy (&ix, &iy); mouse_get_xy (&ix, &iy);
*time = event_timestamp (); *time = event_timestamp ();
...@@ -267,7 +267,7 @@ mouse_check_moved () ...@@ -267,7 +267,7 @@ mouse_check_moved ()
int x, y; int x, y;
mouse_get_xy (&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_x = x;
mouse_last_y = y; mouse_last_y = y;
} }
...@@ -344,9 +344,6 @@ static int term_setup_done; ...@@ -344,9 +344,6 @@ static int term_setup_done;
/* Similar to the_only_frame. */ /* Similar to the_only_frame. */
struct x_output the_only_x_display; 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 /* Support for DOS/V (allows Japanese characters to be displayed on
standard, non-Japanese, ATs). Only supported for DJGPP v2 and later. */ standard, non-Japanese, ATs). Only supported for DJGPP v2 and later. */
...@@ -666,12 +663,13 @@ IT_ring_bell (void) ...@@ -666,12 +663,13 @@ IT_ring_bell (void)
static void static void
IT_set_face (int face) 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; unsigned long fg, bg;
if (!fp) 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 /* The default face for the frame should always be realized and
cached. */ cached. */
if (!fp) if (!fp)
...@@ -688,11 +686,11 @@ IT_set_face (int face) ...@@ -688,11 +686,11 @@ IT_set_face (int face)
switches on this mode (and loses the blinking attribute) at switches on this mode (and loses the blinking attribute) at
startup. */ startup. */
if (fg == (unsigned long)-1) if (fg == (unsigned long)-1)
fg = highlight ? FRAME_BACKGROUND_PIXEL (selected_frame) fg = highlight || fp->tty_reverse_p ? FRAME_BACKGROUND_PIXEL (sf)
: FRAME_FOREGROUND_PIXEL (selected_frame); : FRAME_FOREGROUND_PIXEL (sf);
if (bg == (unsigned long)-1) if (bg == (unsigned long)-1)
bg = highlight ? FRAME_FOREGROUND_PIXEL (selected_frame) bg = highlight || fp->tty_reverse_p ? FRAME_FOREGROUND_PIXEL (sf)
: FRAME_BACKGROUND_PIXEL (selected_frame); : FRAME_BACKGROUND_PIXEL (sf);
if (termscript) if (termscript)
fprintf (termscript, "<FACE %d%s: %d/%d>", fprintf (termscript, "<FACE %d%s: %d/%d>",
face, highlight ? "H" : "", fp->foreground, fp->background); face, highlight ? "H" : "", fp->foreground, fp->background);
...@@ -724,6 +722,7 @@ IT_write_glyphs (struct glyph *str, int str_len) ...@@ -724,6 +722,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
struct coding_system *coding = (CODING_REQUIRE_ENCODING (&terminal_coding) struct coding_system *coding = (CODING_REQUIRE_ENCODING (&terminal_coding)
? &terminal_coding ? &terminal_coding
: &safe_terminal_coding); : &safe_terminal_coding);
struct frame *sf;
/* Do we need to consider conversion of unibyte characters to /* Do we need to consider conversion of unibyte characters to
multibyte? */ multibyte? */
...@@ -735,6 +734,7 @@ IT_write_glyphs (struct glyph *str, int str_len) ...@@ -735,6 +734,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
screen_buf = screen_bp = alloca (str_len * 2); screen_buf = screen_bp = alloca (str_len * 2);
screen_buf_end = screen_buf + 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 /* Since faces get cached and uncached behind our back, we can't
rely on their indices in the cache being consistent across rely on their indices in the cache being consistent across
...@@ -783,8 +783,7 @@ IT_write_glyphs (struct glyph *str, int str_len) ...@@ -783,8 +783,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
{ {
g = !NILP (Vdos_unsupported_char_glyph) g = !NILP (Vdos_unsupported_char_glyph)
? Vdos_unsupported_char_glyph ? Vdos_unsupported_char_glyph
: MAKE_GLYPH (selected_frame, '\177', : MAKE_GLYPH (sf, '\177', GLYPH_FACE (sf, g));
GLYPH_FACE (selected_frame, g));
ch = FAST_GLYPH_CHAR (g); ch = FAST_GLYPH_CHAR (g);
} }
if (COMPOSITE_CHAR_P (ch)) if (COMPOSITE_CHAR_P (ch))
...@@ -792,7 +791,7 @@ IT_write_glyphs (struct glyph *str, int str_len) ...@@ -792,7 +791,7 @@ IT_write_glyphs (struct glyph *str, int str_len)
/* If CH is a composite character, we can display /* If CH is a composite character, we can display
only the first component. */ only the first component. */
g = cmpchar_table[COMPOSITE_CHAR_ID (ch)]->glyph[0], 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); cf = FAST_GLYPH_FACE (g);
} }
...@@ -931,13 +930,13 @@ IT_clear_end_of_line (int first_unused) ...@@ -931,13 +930,13 @@ IT_clear_end_of_line (int first_unused)
int offset = 2 * (new_pos_X + screen_size_X * new_pos_Y); int offset = 2 * (new_pos_X + screen_size_X * new_pos_Y);
extern int fatal_error_in_progress; extern int fatal_error_in_progress;
if (fatal_error_in_progress) if (new_pos_X >= first_unused || fatal_error_in_progress)
return; return;
IT_set_face (0); IT_set_face (0);
if (termscript) if (termscript)
fprintf (termscript, "<CLR:EOL>"); 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); spaces = sp = alloca (i);
while (--j >= 0) while (--j >= 0)
...@@ -950,6 +949,10 @@ IT_clear_end_of_line (int first_unused) ...@@ -950,6 +949,10 @@ IT_clear_end_of_line (int first_unused)
dosmemput (spaces, i, (int)ScreenPrimary + offset); dosmemput (spaces, i, (int)ScreenPrimary + offset);
if (screen_virtual_segment) if (screen_virtual_segment)
dosv_refresh_virtual_screen (offset, i / 2); 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 static void
...@@ -1028,9 +1031,15 @@ IT_cmgoto (FRAME_PTR f) ...@@ -1028,9 +1031,15 @@ IT_cmgoto (FRAME_PTR f)
{ {
/* Only set the cursor to where it should be if the display is /* Only set the cursor to where it should be if the display is
already in sync with the window contents. */ 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; static int previous_pos_X = -1;
update_cursor_pos = 1; /* temporary!!! */
/* If the display is in sync, forget any previous knowledge about /* If the display is in sync, forget any previous knowledge about
cursor position. This is primarily for unexpected events like cursor position. This is primarily for unexpected events like
C-g in the minibuffer. */ C-g in the minibuffer. */
...@@ -1066,6 +1075,7 @@ IT_cmgoto (FRAME_PTR f) ...@@ -1066,6 +1075,7 @@ IT_cmgoto (FRAME_PTR f)
update_cursor_pos = 1; update_cursor_pos = 1;
} }
} }
#endif
if (update_cursor_pos if (update_cursor_pos
&& (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y)) && (current_pos_X != new_pos_X || current_pos_Y != new_pos_Y))
...@@ -1088,14 +1098,12 @@ static void ...@@ -1088,14 +1098,12 @@ static void
IT_reassert_line_highlight (int new, int vpos) IT_reassert_line_highlight (int new, int vpos)
{ {
highlight = new; highlight = new;
IT_set_face (0); /* To possibly clear the highlighting. */
} }
static void static void
IT_change_line_highlight (int new_highlight, int y, int vpos, int first_unused_hpos) IT_change_line_highlight (int new_highlight, int y, int vpos, int first_unused_hpos)
{ {
highlight = new_highlight; highlight = new_highlight;
IT_set_face (0); /* To possibly clear the highlighting. */
IT_cursor_to (vpos, 0); IT_cursor_to (vpos, 0);
IT_clear_end_of_line (first_unused_hpos); IT_clear_end_of_line (first_unused_hpos);
} }
...@@ -1104,8 +1112,6 @@ static void ...@@ -1104,8 +1112,6 @@ static void
IT_update_begin (struct frame *foo) IT_update_begin (struct frame *foo)
{ {
highlight = 0; highlight = 0;
IT_set_face (0); /* To possibly clear the highlighting. */
screen_face = -1;
} }
static void static void
...@@ -1341,6 +1347,30 @@ IT_set_terminal_window (int foo) ...@@ -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 void
IT_set_frame_parameters (f, alist) IT_set_frame_parameters (f, alist)
struct frame *f; struct frame *f;
...@@ -1348,18 +1378,29 @@ IT_set_frame_parameters (f, alist) ...@@ -1348,18 +1378,29 @@ IT_set_frame_parameters (f, alist)
{ {
Lisp_Object tail; Lisp_Object tail;
int length = XINT (Flength (alist)); int length = XINT (Flength (alist));
int i; int i, j;
Lisp_Object *parms Lisp_Object *parms
= (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
Lisp_Object *values Lisp_Object *values
= (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
int redraw; Lisp_Object qreverse = intern ("reverse");
struct face *dflt = NULL; /* Do we have to reverse the foreground and background colors? */
int reverse = EQ (Fcdr (Fassq (qreverse, f->param_alist)), Qt);
if (FRAME_FACE_CACHE (f)) int was_reverse = reverse;
dflt = FACE_FROM_ID (f, DEFAULT_FACE_ID); int redraw = 0, fg_set = 0, bg_set = 0;
unsigned long orig_fg;
redraw = 0; 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. */ /* Extract parm names and values into those vectors. */
i = 0; i = 0;
...@@ -1374,8 +1415,21 @@ IT_set_frame_parameters (f, alist) ...@@ -1374,8 +1415,21 @@ IT_set_frame_parameters (f, alist)
i++; i++;
}