diff options
| author | Karl Heuer | 1995-04-17 23:13:56 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-04-17 23:13:56 +0000 |
| commit | 423cdb46171a8de20a3fe07049da51989fd2acf8 (patch) | |
| tree | 34f5006e474e8c314c818622bb44ada6247d552c /src/buffer.c | |
| parent | 2c782c9f6a5b4b96eb259f3656b4974e6d738033 (diff) | |
| download | emacs-423cdb46171a8de20a3fe07049da51989fd2acf8.tar.gz emacs-423cdb46171a8de20a3fe07049da51989fd2acf8.zip | |
(adjust_overlays_for_insert): New function.
(adjust_overlays_for_delete): New function.
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c index 78f87bfbfa9..d88be20bd80 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1938,6 +1938,40 @@ recenter_overlay_lists (buf, pos) | |||
| 1938 | XSETFASTINT (buf->overlay_center, pos); | 1938 | XSETFASTINT (buf->overlay_center, pos); |
| 1939 | } | 1939 | } |
| 1940 | 1940 | ||
| 1941 | void | ||
| 1942 | adjust_overlays_for_insert (pos, length) | ||
| 1943 | int pos; | ||
| 1944 | int length; | ||
| 1945 | { | ||
| 1946 | /* After an insertion, the lists are still sorted properly, | ||
| 1947 | but we may need to update the value of the overlay center. */ | ||
| 1948 | if (XFASTINT (current_buffer->overlay_center) >= pos) | ||
| 1949 | XSETFASTINT (current_buffer->overlay_center, | ||
| 1950 | XFASTINT (current_buffer->overlay_center) + length); | ||
| 1951 | } | ||
| 1952 | |||
| 1953 | void | ||
| 1954 | adjust_overlays_for_delete (pos, length) | ||
| 1955 | int pos; | ||
| 1956 | int length; | ||
| 1957 | { | ||
| 1958 | if (XFASTINT (current_buffer->overlay_center) < pos) | ||
| 1959 | /* The deletion was to our right. No change needed; the before- and | ||
| 1960 | after-lists are still consistent. */ | ||
| 1961 | ; | ||
| 1962 | else if (XFASTINT (current_buffer->overlay_center) > pos + length) | ||
| 1963 | /* The deletion was to our left. We need to adjust the center value | ||
| 1964 | to account for the change in position, but the lists are consistent | ||
| 1965 | given the new value. */ | ||
| 1966 | XSETFASTINT (current_buffer->overlay_center, | ||
| 1967 | XFASTINT (current_buffer->overlay_center) - length); | ||
| 1968 | else | ||
| 1969 | /* We're right in the middle. There might be things on the after-list | ||
| 1970 | that now belong on the before-list. Recentering will move them, | ||
| 1971 | and also update the center point. */ | ||
| 1972 | recenter_overlay_lists (current_buffer, pos); | ||
| 1973 | } | ||
| 1974 | |||
| 1941 | /* Fix up overlays that were garbled as a result of permuting markers | 1975 | /* Fix up overlays that were garbled as a result of permuting markers |
| 1942 | in the range START through END. Any overlay with at least one | 1976 | in the range START through END. Any overlay with at least one |
| 1943 | endpoint in this range will need to be unlinked from the overlay | 1977 | endpoint in this range will need to be unlinked from the overlay |