+/* Adjust by ADJUST the charstart values in window W
+ after vpos VPOS, which counts relative to the frame
+ (not relative to W itself). */
+
+void
+adjust_window_charstarts (w, vpos, adjust)
+ struct window *w;
+ int vpos;
+ int adjust;
+{
+ int left = XFASTINT (w->left);
+ int top = XFASTINT (w->top);
+ int right = left + window_internal_width (w);
+ int bottom = top + window_internal_height (w);
+ int i;
+
+ for (i = vpos + 1; i < bottom; i++)
+ {
+ int *charstart
+ = FRAME_CURRENT_GLYPHS (XFRAME (WINDOW_FRAME (w)))->charstarts[i];
+ int j;
+ for (j = left; j < right; j++)
+ if (charstart[j] > 0)
+ charstart[j] += adjust;
+ }
+}
+
+/* Check the charstarts values in the area of window W
+ for internal consistency. We cannot check that they are "right";
+ we can only look for something nonsensical. */
+
+verify_charstarts (w)
+ struct window *w;
+{
+ FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
+ int i;
+ int top = XFASTINT (w->top);
+ int bottom = top + window_internal_height (w);
+ int left = XFASTINT (w->left);
+ int right = left + window_internal_width (w);
+ int next_line;
+ int truncate = (XINT (w->hscroll)
+ || (truncate_partial_width_windows
+ && (XFASTINT (w->width) < FRAME_WIDTH (f)))
+ || !NILP (XBUFFER (w->buffer)->truncate_lines));
+
+ for (i = top; i < bottom; i++)
+ {
+ int j;
+ int last;
+ int *charstart = FRAME_CURRENT_GLYPHS (f)->charstarts[i];
+
+ if (i != top)
+ {
+ if (truncate)
+ {
+ /* If we are truncating lines, allow a jump
+ in charstarts from one line to the next. */
+ if (charstart[left] < next_line)
+ abort ();
+ }
+ else
+ {
+ if (charstart[left] != next_line)
+ abort ();
+ }
+ }
+
+ for (j = left; j < right; j++)
+ if (charstart[j] > 0)
+ last = charstart[j];
+ /* Record where the next line should start. */
+ next_line = last;
+ if (BUF_ZV (XBUFFER (w->buffer)) != last)
+ {
+ /* If there's a newline between the two lines, count that. */
+ int endchar = *BUF_CHAR_ADDRESS (XBUFFER (w->buffer), last);
+ if (endchar == '\n')
+ next_line++;
+ }
+ }
+}
+\f