Mercurial > hg > xemacs-beta
comparison src/buffer.h @ 167:85ec50267440 r20-3b10
Import from CVS: tag r20-3b10
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:45:46 +0200 |
parents | 0d2f883870bc |
children | bfd6434d15b3 |
comparison
equal
deleted
inserted
replaced
166:7a77eb660975 | 167:85ec50267440 |
---|---|
73 code to maintain this is just like the code already present in | 73 code to maintain this is just like the code already present in |
74 extent-parent and extent-children. | 74 extent-parent and extent-children. |
75 */ | 75 */ |
76 | 76 |
77 struct buffer_text | 77 struct buffer_text |
78 { | 78 { |
79 Bufbyte *beg; /* Actual address of buffer contents. */ | 79 Bufbyte *beg; /* Actual address of buffer contents. */ |
80 Bytind gpt; /* Index of gap in buffer. */ | 80 Bytind gpt; /* Index of gap in buffer. */ |
81 Bytind z; /* Index of end of buffer. */ | 81 Bytind z; /* Index of end of buffer. */ |
82 Bufpos bufz; /* Equivalent as a Bufpos. */ | 82 Bufpos bufz; /* Equivalent as a Bufpos. */ |
83 int gap_size; /* Size of buffer's gap */ | 83 int gap_size; /* Size of buffer's gap */ |
84 int end_gap_size; /* Size of buffer's end gap */ | 84 int end_gap_size; /* Size of buffer's end gap */ |
85 int modiff; /* This counts buffer-modification events | 85 long modiff; /* This counts buffer-modification events |
86 for this buffer. It is incremented for | 86 for this buffer. It is incremented for |
87 each such event, and never otherwise | 87 each such event, and never otherwise |
88 changed. */ | 88 changed. */ |
89 int save_modiff; /* Previous value of modiff, as of last | 89 long save_modiff; /* Previous value of modiff, as of last |
90 time buffer visited or saved a file. */ | 90 time buffer visited or saved a file. */ |
91 | 91 |
92 #ifdef MULE | 92 #ifdef MULE |
93 /* We keep track of a "known" region for very fast access. | 93 /* We keep track of a "known" region for very fast access. |
94 This information is text-only so it goes here. */ | 94 This information is text-only so it goes here. */ |
95 Bufpos mule_bufmin, mule_bufmax; | 95 Bufpos mule_bufmin, mule_bufmax; |
96 Bytind mule_bytmin, mule_bytmax; | 96 Bytind mule_bytmin, mule_bytmax; |
97 int mule_shifter, mule_three_p; | 97 int mule_shifter, mule_three_p; |
98 | 98 |
99 /* And we also cache 16 positions for fairly fast access near those | 99 /* And we also cache 16 positions for fairly fast access near those |
100 positions. */ | 100 positions. */ |
101 Bufpos mule_bufpos_cache[16]; | 101 Bufpos mule_bufpos_cache[16]; |
102 Bytind mule_bytind_cache[16]; | 102 Bytind mule_bytind_cache[16]; |
103 #endif | 103 #endif |
104 | 104 |
105 /* Change data that goes with the text. */ | 105 /* Change data that goes with the text. */ |
106 struct buffer_text_change_data *changes; | 106 struct buffer_text_change_data *changes; |
107 | 107 |
108 }; | 108 }; |
109 | 109 |
110 struct buffer | 110 struct buffer |
111 { | 111 { |
112 struct lcrecord_header header; | 112 struct lcrecord_header header; |
113 | 113 |
114 /* This structure holds the coordinates of the buffer contents | 114 /* This structure holds the coordinates of the buffer contents |
115 in ordinary buffers. In indirect buffers, this is not used. */ | 115 in ordinary buffers. In indirect buffers, this is not used. */ |
116 struct buffer_text own_text; | 116 struct buffer_text own_text; |
117 | 117 |
118 /* This points to the `struct buffer_text' that is used for this buffer. | 118 /* This points to the `struct buffer_text' that is used for this buffer. |
119 In an ordinary buffer, this is the own_text field above. | 119 In an ordinary buffer, this is the own_text field above. |
120 In an indirect buffer, this is the own_text field of another buffer. */ | 120 In an indirect buffer, this is the own_text field of another buffer. */ |
121 struct buffer_text *text; | 121 struct buffer_text *text; |
122 | 122 |
123 Bytind pt; /* Position of point in buffer. */ | 123 Bytind pt; /* Position of point in buffer. */ |
124 Bufpos bufpt; /* Equivalent as a Bufpos. */ | 124 Bufpos bufpt; /* Equivalent as a Bufpos. */ |
125 Bytind begv; /* Index of beginning of accessible range. */ | 125 Bytind begv; /* Index of beginning of accessible range. */ |
126 Bufpos bufbegv; /* Equivalent as a Bufpos. */ | 126 Bufpos bufbegv; /* Equivalent as a Bufpos. */ |
127 Bytind zv; /* Index of end of accessible range. */ | 127 Bytind zv; /* Index of end of accessible range. */ |
128 Bufpos bufzv; /* Equivalent as a Bufpos. */ | 128 Bufpos bufzv; /* Equivalent as a Bufpos. */ |
129 | 129 |
130 int face_change; /* This is set when a change in how the text | 130 int face_change; /* This is set when a change in how the text should |
131 should be displayed (e.g., font, color) | 131 be displayed (e.g., font, color) is made. */ |
132 is made. */ | 132 |
133 | 133 /* change data indicating what portion of the text has changed |
134 /* change data indicating what portion of the text has changed | 134 since the last time this was reset. Used by redisplay. |
135 since the last time this was reset. Used by redisplay. | 135 Logically we should keep this with the text structure, but |
136 Logically we should keep this with the text structure, but | 136 redisplay resets it for each buffer individually and we don't |
137 redisplay resets it for each buffer individually and we don't | 137 want interference between an indirect buffer and its base |
138 want interference between an indirect buffer and its base | 138 buffer. */ |
139 buffer. */ | 139 struct each_buffer_change_data *changes; |
140 struct each_buffer_change_data *changes; | |
141 | 140 |
142 #ifdef REGION_CACHE_NEEDS_WORK | 141 #ifdef REGION_CACHE_NEEDS_WORK |
143 /* If the long line scan cache is enabled (i.e. the buffer-local | 142 /* If the long line scan cache is enabled (i.e. the buffer-local |
144 variable cache-long-line-scans is non-nil), newline_cache | 143 variable cache-long-line-scans is non-nil), newline_cache |
145 points to the newline cache, and width_run_cache points to the | 144 points to the newline cache, and width_run_cache points to the |
146 width run cache. | 145 width run cache. |
147 | 146 |
148 The newline cache records which stretches of the buffer are | 147 The newline cache records which stretches of the buffer are |
149 known *not* to contain newlines, so that they can be skipped | 148 known *not* to contain newlines, so that they can be skipped |
150 quickly when we search for newlines. | 149 quickly when we search for newlines. |
151 | 150 |
152 The width run cache records which stretches of the buffer are | 151 The width run cache records which stretches of the buffer are |
153 known to contain characters whose widths are all the same. If | 152 known to contain characters whose widths are all the same. If |
154 the width run cache maps a character to a value > 0, that value is | 153 the width run cache maps a character to a value > 0, that value |
155 the character's width; if it maps a character to zero, we don't | 154 is the character's width; if it maps a character to zero, we |
156 know what its width is. This allows compute_motion to process | 155 don't know what its width is. This allows compute_motion to |
157 such regions very quickly, using algebra instead of inspecting | 156 process such regions very quickly, using algebra instead of |
158 each character. See also width_table, below. */ | 157 inspecting each character. See also width_table, below. */ |
159 struct region_cache *newline_cache; | 158 struct region_cache *newline_cache; |
160 struct region_cache *width_run_cache; | 159 struct region_cache *width_run_cache; |
161 #endif | 160 #endif /* REGION_CACHE_NEEDS_WORK */ |
162 | 161 |
163 /* The markers that refer to this buffer. This | 162 /* The markers that refer to this buffer. This is actually a single |
164 is actually a single marker -- successive elements in its marker | 163 marker -- successive elements in its marker `chain' are the other |
165 `chain' are the other markers referring to this buffer */ | 164 markers referring to this buffer */ |
166 struct Lisp_Marker *markers; | 165 struct Lisp_Marker *markers; |
167 | 166 |
168 /* The buffer's extent info. This is its own type, an extent-info | 167 /* The buffer's extent info. This is its own type, an extent-info |
169 object (done this way for ease in marking / finalizing). */ | 168 object (done this way for ease in marking / finalizing). */ |
170 Lisp_Object extent_info; | 169 Lisp_Object extent_info; |
171 | 170 |
172 /* ----------------------------------------------------------------- */ | 171 /* ----------------------------------------------------------------- */ |
173 /* All the stuff above this line is the responsibility of insdel.c, | 172 /* All the stuff above this line is the responsibility of insdel.c, |
174 with some help from marker.c and extents.c. | 173 with some help from marker.c and extents.c. |
175 All the stuff below this line is the responsibility of buffer.c. */ | 174 All the stuff below this line is the responsibility of buffer.c. */ |
176 | 175 |
177 /* In an indirect buffer, this points to the base buffer. | 176 /* In an indirect buffer, this points to the base buffer. |
178 In an ordinary buffer, it is 0. | 177 In an ordinary buffer, it is 0. |
179 We DO mark through this slot. */ | 178 We DO mark through this slot. */ |
180 struct buffer *base_buffer; | 179 struct buffer *base_buffer; |
181 | 180 |
182 /* List of indirect buffers whose base is this buffer. | 181 /* List of indirect buffers whose base is this buffer. |
183 If we are an indirect buffer, this will be nil. | 182 If we are an indirect buffer, this will be nil. |
184 Do NOT mark through this. */ | 183 Do NOT mark through this. */ |
185 Lisp_Object indirect_children; | 184 Lisp_Object indirect_children; |
186 | 185 |
187 /* Flags saying which DEFVAR_PER_BUFFER variables | 186 /* Flags saying which DEFVAR_PER_BUFFER variables |
188 are local to this buffer. */ | 187 are local to this buffer. */ |
189 int local_var_flags; | 188 int local_var_flags; |
190 | 189 |
191 /* Set to the modtime of the visited file when read or written. | 190 /* Set to the modtime of the visited file when read or written. |
192 -1 means visited file was nonexistent. | 191 -1 means visited file was nonexistent. |
193 0 means visited file modtime unknown; in no case complain | 192 0 means visited file modtime unknown; in no case complain |
194 about any mismatch on next save attempt. */ | 193 about any mismatch on next save attempt. */ |
195 int modtime; | 194 int modtime; |
196 | 195 |
197 /* the value of text->modiff at the last auto-save. */ | 196 /* the value of text->modiff at the last auto-save. */ |
198 int auto_save_modified; | 197 int auto_save_modified; |
199 | 198 |
200 /* The time at which we detected a failure to auto-save, | 199 /* The time at which we detected a failure to auto-save, |
201 Or -1 if we didn't have a failure. */ | 200 Or -1 if we didn't have a failure. */ |
202 int auto_save_failure_time; | 201 int auto_save_failure_time; |
203 | 202 |
204 /* Position in buffer at which display started | 203 /* Position in buffer at which display started |
205 the last time this buffer was displayed. */ | 204 the last time this buffer was displayed. */ |
206 int last_window_start; | 205 int last_window_start; |
207 | 206 |
208 /* Everything from here down must be a Lisp_Object */ | 207 /* Everything from here down must be a Lisp_Object */ |
209 | 208 |
210 #define MARKED_SLOT(x) Lisp_Object x | 209 #define MARKED_SLOT(x) Lisp_Object x |
211 #include "bufslots.h" | 210 #include "bufslots.h" |
212 #undef MARKED_SLOT | 211 #undef MARKED_SLOT |
213 }; | 212 }; |
214 | 213 |
215 DECLARE_LRECORD (buffer, struct buffer); | 214 DECLARE_LRECORD (buffer, struct buffer); |
216 #define XBUFFER(x) XRECORD (x, buffer, struct buffer) | 215 #define XBUFFER(x) XRECORD (x, buffer, struct buffer) |
217 #define XSETBUFFER(x, p) XSETRECORD (x, p, buffer) | 216 #define XSETBUFFER(x, p) XSETRECORD (x, p, buffer) |
218 #define BUFFERP(x) RECORDP (x, buffer) | 217 #define BUFFERP(x) RECORDP (x, buffer) |
518 | 517 |
519 #ifdef MULE | 518 #ifdef MULE |
520 | 519 |
521 Emchar non_ascii_charptr_emchar (CONST Bufbyte *ptr); | 520 Emchar non_ascii_charptr_emchar (CONST Bufbyte *ptr); |
522 Bytecount non_ascii_set_charptr_emchar (Bufbyte *ptr, Emchar c); | 521 Bytecount non_ascii_set_charptr_emchar (Bufbyte *ptr, Emchar c); |
523 Bytecount non_ascii_charptr_copy_char (CONST Bufbyte *ptr, | 522 Bytecount non_ascii_charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *ptr2); |
524 Bufbyte *ptr2); | |
525 | 523 |
526 INLINE Emchar charptr_emchar (CONST Bufbyte *ptr); | 524 INLINE Emchar charptr_emchar (CONST Bufbyte *ptr); |
527 INLINE Emchar | 525 INLINE Emchar |
528 charptr_emchar (CONST Bufbyte *ptr) | 526 charptr_emchar (CONST Bufbyte *ptr) |
529 { | 527 { |
860 bytind_to_bufpos(buf, bi): | 858 bytind_to_bufpos(buf, bi): |
861 Given a Bytind, return the equivalent Bufpos. | 859 Given a Bytind, return the equivalent Bufpos. |
862 | 860 |
863 make_bufpos(buf, bi): | 861 make_bufpos(buf, bi): |
864 Given a Bytind, return the equivalent Bufpos as a Lisp Object. | 862 Given a Bytind, return the equivalent Bufpos as a Lisp Object. |
865 | |
866 | |
867 | |
868 */ | 863 */ |
869 | 864 |
870 | 865 |
871 /*----------------------------------------------------------------------*/ | 866 /*----------------------------------------------------------------------*/ |
872 /* working with byte indices */ | 867 /* working with byte indices */ |
1856 | 1851 |
1857 INLINE Emchar UPCASE (struct buffer *buf, Emchar ch); | 1852 INLINE Emchar UPCASE (struct buffer *buf, Emchar ch); |
1858 INLINE Emchar | 1853 INLINE Emchar |
1859 UPCASE (struct buffer *buf, Emchar ch) | 1854 UPCASE (struct buffer *buf, Emchar ch) |
1860 { | 1855 { |
1861 if (DOWNCASE_TABLE_OF (buf, ch) == ch) | 1856 return (DOWNCASE_TABLE_OF (buf, ch) == ch) ? |
1862 return UPCASE_TABLE_OF (buf, ch); | 1857 UPCASE_TABLE_OF (buf, ch) : ch; |
1863 else | |
1864 return ch; | |
1865 } | 1858 } |
1866 | 1859 |
1867 /* Upcase a character known to be not upper case. */ | 1860 /* Upcase a character known to be not upper case. */ |
1868 | 1861 |
1869 #define UPCASE1(buf, ch) UPCASE_TABLE_OF (buf, ch) | 1862 #define UPCASE1(buf, ch) UPCASE_TABLE_OF (buf, ch) |
1871 /* Downcase a character, or make no change if that cannot be done. */ | 1864 /* Downcase a character, or make no change if that cannot be done. */ |
1872 | 1865 |
1873 #define DOWNCASE(buf, ch) DOWNCASE_TABLE_OF (buf, ch) | 1866 #define DOWNCASE(buf, ch) DOWNCASE_TABLE_OF (buf, ch) |
1874 | 1867 |
1875 | 1868 |
1876 /* put it here, somewhat arbitrarily ... its needs to be in *some* | 1869 /* put it here, somewhat arbitrarily ... it needs to be in *some* |
1877 header file. */ | 1870 header file. */ |
1878 DECLARE_LRECORD (range_table, struct Lisp_Range_Table); | 1871 DECLARE_LRECORD (range_table, struct Lisp_Range_Table); |
1879 | 1872 |
1880 #endif /* _XEMACS_BUFFER_H_ */ | 1873 #endif /* _XEMACS_BUFFER_H_ */ |