* floatfns.c (Flogb): Always implement this by calling Flog, even
[bpt/emacs.git] / src / dispnew.c
index 61337b3..e504426 100644 (file)
@@ -1,12 +1,12 @@
 /* Updating of data structures for redisplay.
-   Copyright (C) 1985, 1986, 1987, 1988, 1990,
-   1992 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1988, 1990, 
+   1992, 1993 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -165,7 +165,7 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0,
 }
 
 DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "",
-  "Clear and redisplay all visible frames."
+  "Clear and redisplay all visible frames.")
   ()
 {
   Lisp_Object frame, tail;
@@ -173,7 +173,22 @@ DEFUN ("redraw-display", Fredraw_display, Sredraw_display, 0, 0, "",
   for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
     {
       frame = XCONS (tail)->car;
-      if (FRAME_VISIBLE_P (XFRAME (frame)))
+
+      /* If we simply redrew all visible frames, whether or not they
+        were garbaged, then this would make all frames clear and
+        redraw whenever a new frame is created or an existing frame
+        is de-iconified; those events set the global frame_garbaged
+        flag, to which redisplay responds by calling this function.
+
+        This used to redraw all visible frames; the only advantage of
+        that approach is that if a frame changes from invisible to
+        visible without setting its garbaged flag, it still gets
+        redisplayed.  But that should never happen; since invisible
+        frames are not updated, they should always be marked as
+        garbaged when they become visible again.  If that doesn't
+        happen, it's a bug in the visibility code, not a bug here.  */
+      if (FRAME_VISIBLE_P (XFRAME (frame))
+         && FRAME_GARBAGED_P (XFRAME (frame)))
        Fredraw_frame (frame);
     }
   return Qnil;
@@ -302,9 +317,20 @@ remake_frame_glyphs (frame)
     free_frame_glyphs (frame, FRAME_TEMP_GLYPHS (frame));
 
   if (FRAME_MESSAGE_BUF (frame))
-    FRAME_MESSAGE_BUF (frame)
-      = (char *) xrealloc (FRAME_MESSAGE_BUF (frame),
-                          FRAME_WIDTH (frame) + 1);
+    {
+      /* Reallocate the frame's message buffer; remember that
+        echo_area_glyphs may be pointing here.  */
+      char *old_message_buf = FRAME_MESSAGE_BUF (frame);
+
+      FRAME_MESSAGE_BUF (frame)
+       = (char *) xrealloc (FRAME_MESSAGE_BUF (frame),
+                            FRAME_WIDTH (frame) + 1);
+
+      if (echo_area_glyphs == old_message_buf)
+       echo_area_glyphs = FRAME_MESSAGE_BUF (frame);
+      if (previous_echo_glyphs == old_message_buf)
+       previous_echo_glyphs = FRAME_MESSAGE_BUF (frame);
+    }
   else
     FRAME_MESSAGE_BUF (frame)
       = (char *) xmalloc (FRAME_WIDTH (frame) + 1);
@@ -828,9 +854,9 @@ direct_output_for_insert (g)
 #endif /* COMPILER_REGISTER_BUG */
     int vpos = FRAME_CURSOR_Y (frame);
 
-  /* Give up if about to continue line */
-  if (hpos - XFASTINT (w->left) + 1 + 1 >= XFASTINT (w->width)
-
+  /* Give up if about to continue line */
+  if (hpos >= XFASTINT (w->left) + window_internal_width (w) - 1
+    
   /* Avoid losing if cursor is in invisible text off left margin */
       || (XINT (w->hscroll) && hpos == XFASTINT (w->left))
     
@@ -881,10 +907,7 @@ direct_output_forward_char (n)
   if ((FRAME_CURSOR_X (frame) == XFASTINT (w->left)
        && (XINT (w->hscroll) || n < 0))
       || (n > 0
-         && (FRAME_CURSOR_X (frame) + 1
-             >= (XFASTINT (w->left) + XFASTINT (w->width)
-                 - (XFASTINT (w->width) < FRAME_WIDTH (frame))
-                 - 1)))
+         && (FRAME_CURSOR_X (frame) + 1 >= window_internal_width (w) - 1))
       || cursor_in_echo_area)
     return 0;
 
@@ -1176,9 +1199,7 @@ buffer_posn_from_coords (window, col, line)
   /* The actual width of the window is window->width less one for the
      DISP_CONTINUE_GLYPH, and less one if it's not the rightmost
      window.  */
-  int window_width = (XFASTINT (window->width) - 1
-                     - (XFASTINT (window->width) + window_left
-                        != FRAME_WIDTH (XFRAME (window->frame))));
+  int window_width = window_internal_width (window) - 1;
 
   int startp = marker_position (window->start);
 
@@ -1233,7 +1254,7 @@ count_match (str1, str2)
 /* Char insertion/deletion cost vector, from term.c */
 extern int *char_ins_del_vector;
 
-#define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_HEIGHT((f))])
+#define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_WIDTH((f))])
 
 static void
 update_line (frame, vpos)
@@ -1858,7 +1879,7 @@ sit_for (sec, usec, reading, display)
     return Qt;
 
 #ifdef SIGIO
-  gobble_input ();
+  gobble_input (0);
 #endif
 
   XSET (read_kbd, Lisp_Int, reading ? -1 : 1);