]> code.delx.au - gnu-emacs/blobdiff - src/dispnew.c
Lowercase the first letter in the header.
[gnu-emacs] / src / dispnew.c
index 131cc9340047c0083f50a17c4f2fe9aee80a9071..35c1b87a88651f2ffcab719d0bb3a34e0890446b 100644 (file)
@@ -1,5 +1,5 @@
 /* Updating of data structures for redisplay.
-   Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 97, 98, 1999, 2000, 2001
+   Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 97, 98, 1999, 2000, 2001, 2002
        Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -60,9 +60,9 @@ Boston, MA 02111-1307, USA.  */
 #include "w32term.h"
 #endif /* HAVE_NTGUI */
 
-#ifdef macintosh
+#ifdef MAC_OS
 #include "macterm.h"
-#endif /* macintosh */
+#endif /* MAC_OS */
 
 /* Include systime.h after xterm.h to avoid double inclusion of time.h.  */
 
@@ -101,7 +101,7 @@ Boston, MA 02111-1307, USA.  */
 #endif
 #endif /* not __GNU_LIBRARY__ */
 
-#if defined(HAVE_TERM_H) && defined (LINUX) && defined (HAVE_LIBNCURSES)
+#if defined(HAVE_TERM_H) && defined (GNU_LINUX) && defined (HAVE_LIBNCURSES)
 #include <term.h>              /* for tgetent */
 #endif
 \f
@@ -211,7 +211,7 @@ int inverse_video;
 
 /* Line speed of the terminal.  */
 
-int baud_rate;
+EMACS_INT baud_rate;
 
 /* Either nil or a symbol naming the window system under which Emacs
    is running.  */
@@ -238,7 +238,7 @@ Lisp_Object Vglyph_table;
 Lisp_Object Vstandard_display_table;
 
 /* Nonzero means reading single-character input with prompt so put
-   cursor on mini-buffer after the prompt.  positive means at end of
+   cursor on mini-buffer after the prompt.  Positive means at end of
    text in echo area; negative means at beginning of line.  */
 
 int cursor_in_echo_area;
@@ -358,7 +358,7 @@ static void add_window_display_history P_ ((struct window *, char *, int));
 
 /* Add to the redisplay history how window W has been displayed.
    MSG is a trace containing the information how W's glyph matrix
-   has been contructed.  PAUSED_P non-zero means that the update
+   has been constructed.  PAUSED_P non-zero means that the update
    has been interrupted for pending input.  */
 
 static void
@@ -624,7 +624,7 @@ adjust_glyph_matrix (w, matrix, x, y, dim)
   int left = -1, right = -1;
   int window_x, window_y, window_width = -1, window_height;
 
-  /* See if W had a top line that has disappeared now, or vice versa.  */
+  /* See if W had a header line that has disappeared now, or vice versa.  */
   if (w)
     {
       header_line_p = WINDOW_WANTS_HEADER_LINE_P (w);
@@ -1124,7 +1124,7 @@ clear_glyph_row (row)
         Redisplay outputs such glyphs, and flickering effects were
         the result.  This also depended on the contents of memory
         returned by xmalloc.  If flickering happens again, activate
-        the code below If the flickering is gone with that, chances
+        the code below If the flickering is gone with that, chances
         are that the flickering has the same reason as here.  */
   bzero (p[0], (char *) p[LAST_AREA] - (char *) p[0]);
 #endif
@@ -1407,7 +1407,7 @@ line_hash_code (row)
 }
 
 
-/* Return the cost of drawing line VPOS In MATRIX.  The cost equals
+/* Return the cost of drawing line VPOS in MATRIX.  The cost equals
    the number of characters in the line.  If must_write_spaces is
    zero, leading and trailing spaces are ignored.  */
 
@@ -1571,7 +1571,7 @@ free_glyph_pool (pool)
 {
   if (pool)
     {
-      /* More freed than allocated? */
+      /* More freed than allocated?  */
       --glyph_pool_count;
       xassert (glyph_pool_count >= 0);
 
@@ -1619,7 +1619,7 @@ realloc_glyph_pool (pool, matrix_dim)
       pool->nglyphs = needed;
     }
 
-  /* Remember the number of rows and columns because (a) we use then
+  /* Remember the number of rows and columns because (a) we use them
      to do sanity checks, and (b) the number of columns determines
      where rows in the frame matrix start---this must be available to
      determine pointers to rows of window sub-matrices.  */
@@ -1782,7 +1782,7 @@ check_matrix_invariants (w)
 
    CHANGED_LEAF_MATRIX set if the dimension or location of a matrix of
    any window in the tree will be changed or have been changed (see
-   DIM_ONLY_P).
+   DIM_ONLY_P)
 
    *WINDOW_CHANGE_FLAGS must be initialized by the caller of this
    function.
@@ -1874,7 +1874,7 @@ allocate_matrices_for_frame_redisplay (window, x, y, dim_only_p,
       w = XWINDOW (window);
 
       /* Get the dimension of the window sub-matrix for W, depending
-        on whether this a combination or a leaf window.  */
+        on whether this is a combination or a leaf window.  */
       if (!NILP (w->hchild))
        dim = allocate_matrices_for_frame_redisplay (w->hchild, x, y, 
                                                     dim_only_p,
@@ -1979,7 +1979,7 @@ required_matrix_height (w)
              /* One partially visible line at the top and
                 bottom of the window.  */
              + 2
-             /* 2 for top and mode line.  */
+             /* 2 for header and mode line.  */
              + 2);
     }
 #endif /* HAVE_WINDOW_SYSTEM */
@@ -2188,7 +2188,7 @@ fake_current_matrices (window)
 
 
 /* Save away the contents of frame F's current frame matrix.  Value is
-   a glyph matrix holding the contents of F's current frame matrix. '*/
+   a glyph matrix holding the contents of F's current frame matrix.  */
 
 static struct glyph_matrix *
 save_current_matrix (f)
@@ -2997,7 +2997,7 @@ mirrored_line_dance (matrix, unchanged_at_top, nlines, copy_from,
        new_rows[i].enabled_p = 0;
     }
 
-  /* Do the same for window matrices, if MATRIX Is a frame matrix.  */
+  /* Do the same for window matrices, if MATRIX is a frame matrix.  */
   if (frame_matrix_frame)
     mirror_line_dance (XWINDOW (frame_matrix_frame->root_window),
                       unchanged_at_top, nlines, copy_from, retained_p);
@@ -3271,7 +3271,7 @@ window_to_frame_vpos (w, vpos)
 
 
 /* Translate horizontal position HPOS which is relative to window W to
-   a vertical position relative to W's frame.  */
+   a horizontal position relative to W's frame.  */
 
 static int
 window_to_frame_hpos (w, hpos)
@@ -3397,7 +3397,7 @@ direct_output_for_insert (g)
   struct glyph_row *glyph_row;
   struct glyph *glyphs, *glyph, *end;
   int n;
-  /* Non-null means that Redisplay of W is based on window matrices.  */
+  /* Non-null means that redisplay of W is based on window matrices.  */
   int window_redisplay_p = FRAME_WINDOW_P (f);
   /* Non-null means we are in overwrite mode.  */
   int overwrite_p = !NILP (current_buffer->overwrite_mode);
@@ -3655,14 +3655,7 @@ direct_output_for_insert (g)
   fflush (stdout);
 
   TRACE ((stderr, "direct output for insert\n"));
-
-  UNCHANGED_MODIFIED = MODIFF;
-  BEG_UNCHANGED = GPT - BEG;
-  XSETFASTINT (w->last_point, PT);
-  w->last_cursor = w->cursor;
-  XSETFASTINT (w->last_modified, MODIFF);
-  XSETFASTINT (w->last_overlay_modified, OVERLAY_MODIFF);
-
+  mark_window_display_accurate (it.window, 1);
   redisplay_performed_directly_p = 1;
   return 1;
 }
@@ -3724,8 +3717,8 @@ direct_output_forward_char (n)
   row = MATRIX_ROW (w->current_matrix, w->cursor.vpos);
 
   /* Give up if PT is outside of the last known cursor row.  */
-  if (PT <= MATRIX_ROW_START_BYTEPOS (row)
-      || PT >= MATRIX_ROW_END_BYTEPOS (row))
+  if (PT <= MATRIX_ROW_START_CHARPOS (row)
+      || PT >= MATRIX_ROW_END_CHARPOS (row))
     return 0;
 
   set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0);
@@ -3799,12 +3792,13 @@ update_frame (f, force_p, inhibit_hairy_id_p)
       /* Update the tool-bar window, if present.  */
       if (WINDOWP (f->tool_bar_window))
        {
-         Lisp_Object tem;
          struct window *w = XWINDOW (f->tool_bar_window);
 
          /* Update tool-bar window.  */
          if (w->must_be_updated_p)
            {
+             Lisp_Object tem;
+
              update_window (w, 1);
              w->must_be_updated_p = 0;
 
@@ -3996,7 +3990,7 @@ redraw_overlapping_rows (w, yb)
          if (row->used[RIGHT_MARGIN_AREA])
            rif->fix_overlapping_area (w, row, RIGHT_MARGIN_AREA);
 
-         /* Record in neighbor rows that ROW overwrites part of their
+         /* Record in neighbour rows that ROW overwrites part of their
             display.  */
          if (row->phys_ascent > row->ascent && i > 0)
            MATRIX_ROW (w->current_matrix, i - 1)->overlapped_p = 1;
@@ -4077,8 +4071,8 @@ update_window (w, force_p)
       rif->update_window_begin_hook (w);
       yb = window_text_bottom_y (w);
 
-      /* If window has a top line, update it before everything else.
-        Adjust y-positions of other rows by the top line height.  */
+      /* If window has a header line, update it before everything else.
+        Adjust y-positions of other rows by the header line height.  */
       row = desired_matrix->rows;
       end = row + desired_matrix->nrows - 1;
       
@@ -4123,7 +4117,7 @@ update_window (w, force_p)
          changed_p = 1;
        }
 
-      /* Update the top mode line after scrolling because a new top
+      /* Update the header line after scrolling because a new header
         line would otherwise overwrite lines at the top of the window
         that can be scrolled.  */
       if (header_line_row && header_line_row->enabled_p)
@@ -4140,7 +4134,7 @@ update_window (w, force_p)
            int vpos = MATRIX_ROW_VPOS (row, desired_matrix);
            int i;
            
-           /* We'll Have to play a little bit with when to
+           /* We'll have to play a little bit with when to
               detect_input_pending.  If it's done too often,
               scrolling large windows with repeated scroll-up
               commands will too quickly pause redisplay.  */
@@ -4169,7 +4163,7 @@ update_window (w, force_p)
       
     set_cursor:
       
-      /* Fix the appearance of overlapping(overlapped rows.  */
+      /* Fix the appearance of overlapping/overlapped rows.  */
       if (!paused_p && !w->pseudo_window_p)
        {
          if (changed_p && rif->fix_overlapping_area)
@@ -4273,6 +4267,16 @@ update_text_area (w, vpos)
       /* Clear to end of window.  */
       rif->clear_end_of_line (-1);
       changed_p = 1;
+
+      /* This erases the cursor.  We do this here because
+         notice_overwritten_cursor cannot easily check this, which
+         might indicate that the whole functionality of
+         notice_overwritten_cursor would better be implemented here.
+         On the other hand, we need notice_overwritten_cursor as long
+         as mouse highlighting is done asynchronously outside of
+         redisplay.  */
+      if (vpos == w->phys_cursor.vpos)
+       w->phys_cursor_on_p = 0;
     }
   else
     {
@@ -4683,10 +4687,6 @@ static int runs_size;
 
 static struct run **runs;
 
-static struct row_entry *add_row_entry P_ ((struct window *,
-                                           struct glyph_row *));
-
-
 /* Add glyph row ROW to the scrolling hash table during the scrolling
    of window W.  */
 
@@ -4718,7 +4718,7 @@ add_row_entry (w, row)
 
 
 /* Try to reuse part of the current display of W by scrolling lines.
-   HEADER_LINE_P non-zero means W has a top mode line.
+   HEADER_LINE_P non-zero means W has a header line.
 
    The algorithm is taken from Communications of the ACM, Apr78 "A
    Technique for Isolating Differences Between Files."  It should take
@@ -5107,7 +5107,7 @@ update_frame_1 (f, force_p, inhibit_id_p)
 #ifdef EMACS_OUTQSIZE
                      if (EMACS_OUTQSIZE (0, &outq) < 0)
                        /* Probably not a tty.  Ignore the error and reset
-                        * the outq count.  */
+                          the outq count.  */
                        outq = PENDING_OUTPUT_COUNT (stdout);
 #endif
                      outq *= 10;
@@ -5717,7 +5717,7 @@ buffer_posn_from_coords (w, x, y, object, pos)
 
 
 /* Value is the string under window-relative coordinates X/Y in the
-   mode or top line of window W, or nil if none.  MODE_LINE_P non-zero
+   mode or header line of window W, or nil if none.  MODE_LINE_P non-zero
    means look at the mode line.  *CHARPOS is set to the position in
    the string returned.  */
 
@@ -5740,12 +5740,12 @@ mode_line_string (w, x, y, mode_line_p, charpos)
 
   if (row->mode_line_p && row->enabled_p)
     {
-      /* The mode lines are displayed over scroll bars and bitmap
-        areas, and X is window-relative.  Correct X by the scroll bar
-        and bitmap area width.  */
+      /* The mode lines are displayed over scroll bars and fringes,
+        and X is window-relative.  Correct X by the scroll bar
+        and fringe width.  */
       if (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
        x += FRAME_SCROLL_BAR_COLS (f) * CANON_X_UNIT (f);
-      x += FRAME_LEFT_FLAGS_AREA_WIDTH (f);
+      x += FRAME_LEFT_FRINGE_WIDTH (f);
 
       /* Find the glyph under X.  If we find one with a string object,
          it's the one we were looking for.  */
@@ -5764,6 +5764,57 @@ mode_line_string (w, x, y, mode_line_p, charpos)
 }
 
 
+/* Value is the string under window-relative coordinates X/Y in either
+   marginal area, or nil if none.  *CHARPOS is set to the position in
+   the string returned.  */
+
+Lisp_Object
+marginal_area_string (w, x, y, area, charpos)
+     struct window *w;
+     int x, y;
+     int area;
+     int *charpos;
+{
+  struct glyph_row *row = w->current_matrix->rows;
+  struct glyph *glyph, *end;
+  int x0, i, wy = y;
+  Lisp_Object string = Qnil;
+
+  if (area == 6)
+    area = LEFT_MARGIN_AREA;
+  else if (area == 7)
+    area = RIGHT_MARGIN_AREA;
+  else
+    abort ();
+
+  for (i = 0; row->enabled_p && i < w->current_matrix->nrows; ++i, ++row)
+    if (wy >= row->y && wy < MATRIX_ROW_BOTTOM_Y (row))
+      break;
+
+  if (row->enabled_p)
+    {
+      /* Find the glyph under X.  If we find one with a string object,
+        it's the one we were looking for.  */
+      glyph = row->glyphs[area];
+      end = glyph + row->used[area];
+      if (area == RIGHT_MARGIN_AREA)
+       x0 = (window_box_width (w, TEXT_AREA)
+             + window_box_width (w, LEFT_MARGIN_AREA));
+      else
+       x0 = 0;
+      for (; glyph < end; x0 += glyph->pixel_width, ++glyph)
+       if (x >= x0 && x < x0 + glyph->pixel_width)
+         {
+           string = glyph->object;
+           *charpos = glyph->charpos;
+           break;
+         }
+    }
+
+  return string;
+}
+
+
 /***********************************************************************
                         Changing Frame Sizes
  ***********************************************************************/
@@ -6107,7 +6158,7 @@ Emacs was built without floating point support.
   /* Assure that 0 <= usec < 1000000.  */
   if (usec < 0)
     {
-      /* We can't rely on the rounding being correct if user is negative.  */
+      /* We can't rely on the rounding being correct if usec is negative.  */
       if (-1000000 < usec)
        sec--, usec += 1000000;
       else
@@ -6138,7 +6189,7 @@ Emacs was built without floating point support.
 #else /* not VMS */
 /* The reason this is done this way 
     (rather than defined (H_S) && defined (H_T))
-   is because the VMS preprocessor doesn't grok `defined' */
+   is because the VMS preprocessor doesn't grok `defined' */
 #ifdef HAVE_SELECT
   EMACS_GET_TIME (end_time);
   EMACS_SET_SECS_USECS (timeout, sec, usec);
@@ -6178,7 +6229,7 @@ sit_for (sec, usec, reading, display, initial_display)
 
   swallow_events (display);
 
-  if (detect_input_pending_run_timers (display))
+  if (detect_input_pending_run_timers (display) || !NILP (Vexecuting_macro))
     return Qnil;
 
   if (initial_display)
@@ -6397,7 +6448,7 @@ init_display ()
 #else
       Vwindow_system_version = make_number (10);
 #endif
-#if defined (LINUX) && defined (HAVE_LIBNCURSES)
+#if defined (GNU_LINUX) && defined (HAVE_LIBNCURSES)
       /* In some versions of ncurses,
         tputs crashes if we have not called tgetent.
         So call tgetent.  */
@@ -6418,7 +6469,7 @@ init_display ()
     }
 #endif /* HAVE_NTGUI */
 
-#ifdef macintosh
+#ifdef MAC_OS
   if (!inhibit_window_system) 
     {
       Vwindow_system = intern ("mac");
@@ -6426,7 +6477,7 @@ init_display ()
       adjust_frame_glyphs_initially ();
       return;
     }
-#endif /* macintosh */
+#endif /* MAC_OS */
 
   /* If no window system has been specified, try to use the terminal.  */
   if (! isatty (0))
@@ -6435,7 +6486,7 @@ init_display ()
       exit (1);
     }
 
-  /* Look at the TERM variable */
+  /* Look at the TERM variable */
   terminal_type = (char *) getenv ("TERM");
   if (!terminal_type)
     {
@@ -6615,8 +6666,9 @@ Emacs's frame display when you reenter Emacs.
 It is up to you to set this variable if your terminal can do that.  */);
   
   DEFVAR_LISP ("window-system", &Vwindow_system,
-              doc: /* A symbol naming the window-system under which Emacs is running
-\(such as `x'), or nil if emacs is running on an ordinary terminal.  */);
+              doc: /* Name of window system that Emacs is displaying through.
+The value is a symbol--for instance, `x' for X windows.
+The value is nil if Emacs is using a text-only terminal.  */);
   
   DEFVAR_LISP ("window-system-version", &Vwindow_system_version,
               doc: /* The version number of the window system in use.