Mercurial > emacs
changeset 11473:24ede15e0aaa
(adjust_overlays_for_insert): New function.
(adjust_overlays_for_delete): New function.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Mon, 17 Apr 1995 23:13:56 +0000 |
parents | b2ccbdb6336f |
children | 510885be2758 |
files | src/buffer.c |
diffstat | 1 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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