# HG changeset patch # User Karl Heuer # Date 798160436 0 # Node ID 24ede15e0aaacab66d6134901dc049ef89bc3b31 # Parent b2ccbdb6336f04ce0a9c64854a24057282b27ec3 (adjust_overlays_for_insert): New function. (adjust_overlays_for_delete): New function. diff -r b2ccbdb6336f -r 24ede15e0aaa src/buffer.c --- a/src/buffer.c Mon Apr 17 23:12:34 1995 +0000 +++ b/src/buffer.c Mon Apr 17 23:13:56 1995 +0000 @@ -1938,6 +1938,40 @@ 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