]> code.delx.au - gnu-emacs/commitdiff
(adjust_overlays_for_insert): New function.
authorKarl Heuer <kwzh@gnu.org>
Mon, 17 Apr 1995 23:13:56 +0000 (23:13 +0000)
committerKarl Heuer <kwzh@gnu.org>
Mon, 17 Apr 1995 23:13:56 +0000 (23:13 +0000)
(adjust_overlays_for_delete): New function.

src/buffer.c

index 78f87bfbfa9b4da5505c44f5977aa2368dc4f5e1..d88be20bd80d5c93bc6e988be574eb3ebaae8c03 100644 (file)
@@ -1938,6 +1938,40 @@ recenter_overlay_lists (buf, pos)
   XSETFASTINT (buf->overlay_center, pos);
 }
 
+void
+adjust_overlays_for_insert (pos, length)
+     int pos;
+     int length;
+{
+  /* After an insertion, the lists are still sorted properly,
+     but we may need to update the value of the overlay center.  */
+  if (XFASTINT (current_buffer->overlay_center) >= pos)
+    XSETFASTINT (current_buffer->overlay_center,
+                XFASTINT (current_buffer->overlay_center) + length);
+}
+
+void
+adjust_overlays_for_delete (pos, length)
+     int pos;
+     int length;
+{
+  if (XFASTINT (current_buffer->overlay_center) < pos)
+    /* The deletion was to our right.  No change needed; the before- and
+       after-lists are still consistent.  */
+    ;
+  else if (XFASTINT (current_buffer->overlay_center) > pos + length)
+    /* The deletion was to our left.  We need to adjust the center value
+       to account for the change in position, but the lists are consistent
+       given the new value.  */
+    XSETFASTINT (current_buffer->overlay_center,
+                XFASTINT (current_buffer->overlay_center) - length);
+  else
+    /* We're right in the middle.  There might be things on the after-list
+       that now belong on the before-list.  Recentering will move them,
+       and also update the center point.  */
+    recenter_overlay_lists (current_buffer, pos);
+}
+
 /* Fix up overlays that were garbled as a result of permuting markers
    in the range START through END.  Any overlay with at least one
    endpoint in this range will need to be unlinked from the overlay