1 /* Buffer insertion/deletion and gap motion for XEmacs.
2 Copyright (C) 1985-1994 Free Software Foundation, Inc.
4 This file is part of SXEmacs
6 SXEmacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 SXEmacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* Synched up with: Not in FSF. */
22 /* Mostly rewritten by Ben Wing. */
24 #ifndef INCLUDED_insdel_h_
25 #define INCLUDED_insdel_h_
27 /************************************************************************/
28 /* changing a buffer's text */
29 /************************************************************************/
31 int begin_multiple_change(struct buffer *buf, Bufpos start, Bufpos end);
32 void end_multiple_change(struct buffer *buf, int count);
34 /* flags for functions below */
36 #define INSDEL_BEFORE_MARKERS 1
37 #define INSDEL_NO_LOCKING 2
39 Charcount buffer_insert_string_1(struct buffer *buf, Bufpos pos,
40 const Bufbyte * nonreloc, Lisp_Object reloc,
41 Bytecount offset, Bytecount length, int flags);
42 Charcount buffer_insert_raw_string_1(struct buffer *buf, Bufpos pos,
43 const Bufbyte * nonreloc,
44 Bytecount length, int flags);
45 Charcount buffer_insert_lisp_string_1(struct buffer *buf, Bufpos pos,
46 Lisp_Object str, int flags);
47 Charcount buffer_insert_c_string_1(struct buffer *buf, Bufpos pos,
48 const char *s, int flags);
49 Charcount buffer_insert_emacs_char_1(struct buffer *buf, Bufpos pos,
50 Emchar ch, int flags);
51 Charcount buffer_insert_c_char_1(struct buffer *buf, Bufpos pos, char c,
53 Charcount buffer_insert_from_buffer_1(struct buffer *buf, Bufpos pos,
54 struct buffer *buf2, Bufpos pos2,
55 Charcount length, int flags);
57 /* Macros for insertion functions that insert at point after markers.
58 All of these can GC. */
60 #define buffer_insert_string(buf, nonreloc, reloc, offset, length) \
61 buffer_insert_string_1 (buf, -1, nonreloc, reloc, offset, length, 0)
62 #define buffer_insert_raw_string(buf, string, length) \
63 buffer_insert_raw_string_1 (buf, -1, string, length, 0)
64 #define buffer_insert_c_string(buf, s) \
65 buffer_insert_c_string_1 (buf, -1, s, 0)
66 #define buffer_insert_lisp_string(buf, str) \
67 buffer_insert_lisp_string_1 (buf, -1, str, 0)
68 #define buffer_insert_c_char(buf, c) \
69 buffer_insert_c_char_1 (buf, -1, c, 0)
70 #define buffer_insert_emacs_char(buf, ch) \
71 buffer_insert_emacs_char_1 (buf, -1, ch, 0)
72 #define buffer_insert_from_buffer(buf, b, index, length) \
73 buffer_insert_from_buffer_1 (buf, -1, b, index, length, 0)
75 void buffer_delete_range(struct buffer *buf, Bufpos from, Bufpos to, int flags);
76 void buffer_replace_char(struct buffer *b, Bufpos pos, Emchar ch,
77 int not_real_change, int force_lock_check);
79 /************************************************************************/
80 /* tracking buffer changes */
81 /************************************************************************/
83 /* Split into two parts. One part goes with a buffer's text (possibly
84 shared), the other with the buffer itself. */
86 struct buffer_text_change_data {
87 /* multiple change stuff */
88 int in_multiple_change;
89 Bufpos mc_begin, mc_orig_end, mc_new_end;
90 int mc_begin_signaled;
93 struct each_buffer_change_data {
94 Charcount begin_unchanged, end_unchanged;
95 /* redisplay needs to know if a newline was deleted so its
96 incremental-redisplay algorithm will fail */
97 int newline_was_deleted;
98 Charcount begin_extent_unchanged, end_extent_unchanged;
101 /* Number of characters at the beginning and end of the buffer that
102 have not changed since the last call to buffer_reset_changes().
103 If no changes have occurred since then, both values will be -1.
105 "Changed" means that the text has changed. */
107 #define BUF_BEGIN_UNCHANGED(buf) ((buf)->changes->begin_unchanged)
108 #define BUF_END_UNCHANGED(buf) ((buf)->changes->end_unchanged)
110 /* Number of characters at the beginning and end of the buffer that
111 have not had a covering extent change since the last call to
112 buffer_reset_changes (). If no changes have occurred since then,
113 both values will be -1.
115 "Changed" means that the extents covering the text have changed. */
117 #define BUF_EXTENT_BEGIN_UNCHANGED(buf) \
118 ((buf)->changes->begin_extent_unchanged)
119 #define BUF_EXTENT_END_UNCHANGED(buf) \
120 ((buf)->changes->end_extent_unchanged)
122 #define BUF_NEWLINE_WAS_DELETED(buf) \
123 ((buf)->changes->newline_was_deleted)
125 void buffer_extent_signal_changed_region(struct buffer *buf,
126 Bufpos start, Bufpos end);
127 void buffer_reset_changes(struct buffer *buf);
129 /************************************************************************/
130 /* other related functions */
131 /************************************************************************/
133 Memind do_marker_adjustment(Memind mpos, Memind from,
134 Memind to, Bytecount amount);
136 void fixup_internal_substring(const Bufbyte * nonreloc,
138 Bytecount offset, Bytecount * len);
141 void font_lock_maybe_update_syntactic_caches(struct buffer *buf,
143 Bufpos orig_end, Bufpos new_end);
144 void font_lock_buffer_was_killed(struct buffer *buf);
146 void barf_if_buffer_read_only(struct buffer *buf, Bufpos from, Bufpos to);
148 void init_buffer_text(struct buffer *b);
149 void uninit_buffer_text(struct buffer *b);
151 #endif /* INCLUDED_insdel_h_ */