Mercurial > emacs
comparison src/buffer.h @ 17023:78f7b873184b
(BEGV_ADDR, PT_ADDR, ZV_ADDR): Use macro POS_ADDR.
(Z_ADDR, BUF_GPT_ADDR, BUF_Z_ADDR): New macros.
(struct buffer): New members `category_table',
`direction_reserved', and `enable-multibyte-characters'.
(POS_ADDR): New macro used at all places instead of &FETCH_CHAR.
(FETCH_BYTE): New macro used at any places to check the argument
against an ASCII character.
(FETCH_MULTIBYTE_CHAR): New macro used at any places to get a
character code of the argument when it is known to be a multibyte
character.
(_fetch_multibyte_char_p, _fetch_multibyte_char_len): New
variables.
(FETCH_CHAR): Use macros FETCH_MULTIBYTE_CHAR and FETCH_BYTE.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 20 Feb 1997 06:45:13 +0000 |
parents | e07564b5ca82 |
children | e3db9264789e |
comparison
equal
deleted
inserted
replaced
17022:907fb167f7de | 17023:78f7b873184b |
---|---|
68 | 68 |
69 /* Address of beginning of buffer. */ | 69 /* Address of beginning of buffer. */ |
70 #define BEG_ADDR (current_buffer->text->beg) | 70 #define BEG_ADDR (current_buffer->text->beg) |
71 | 71 |
72 /* Address of beginning of accessible range of buffer. */ | 72 /* Address of beginning of accessible range of buffer. */ |
73 #define BEGV_ADDR (&FETCH_CHAR (current_buffer->begv)) | 73 #define BEGV_ADDR (POS_ADDR (current_buffer->begv)) |
74 | 74 |
75 /* Address of point in buffer. */ | 75 /* Address of point in buffer. */ |
76 #define PT_ADDR (&FETCH_CHAR (current_buffer->pt)) | 76 #define PT_ADDR (POS_ADDR (current_buffer->pt)) |
77 | 77 |
78 /* Address of beginning of gap in buffer. */ | 78 /* Address of beginning of gap in buffer. */ |
79 #define GPT_ADDR (current_buffer->text->beg + current_buffer->text->gpt - 1) | 79 #define GPT_ADDR (current_buffer->text->beg + current_buffer->text->gpt - 1) |
80 | 80 |
81 /* Address of end of gap in buffer. */ | 81 /* Address of end of gap in buffer. */ |
82 #define GAP_END_ADDR (current_buffer->text->beg + current_buffer->text->gpt + current_buffer->text->gap_size - 1) | 82 #define GAP_END_ADDR (current_buffer->text->beg + current_buffer->text->gpt + current_buffer->text->gap_size - 1) |
83 | 83 |
84 /* Address of end of accessible range of buffer. */ | 84 /* Address of end of accessible range of buffer. */ |
85 #define ZV_ADDR (&FETCH_CHAR (current_buffer->zv)) | 85 #define ZV_ADDR (POS_ADDR (current_buffer->zv)) |
86 | |
87 /* Address of end of buffer. */ | |
88 #define Z_ADDR (current_buffer->text->beg + current_buffer->text->gap_size + current_buffer->text->z - 1) | |
86 | 89 |
87 /* Size of gap. */ | 90 /* Size of gap. */ |
88 #define GAP_SIZE (current_buffer->text->gap_size) | 91 #define GAP_SIZE (current_buffer->text->gap_size) |
89 | 92 |
90 /* Now similar macros for a specified buffer. | 93 /* Now similar macros for a specified buffer. |
127 /* Marker chain of buffer. */ | 130 /* Marker chain of buffer. */ |
128 #define BUF_MARKERS(buf) ((buf)->text->markers) | 131 #define BUF_MARKERS(buf) ((buf)->text->markers) |
129 | 132 |
130 /* Address of beginning of buffer. */ | 133 /* Address of beginning of buffer. */ |
131 #define BUF_BEG_ADDR(buf) ((buf)->text->beg) | 134 #define BUF_BEG_ADDR(buf) ((buf)->text->beg) |
135 | |
136 /* Address of beginning of gap of buffer. */ | |
137 #define BUF_GPT_ADDR(buf) ((buf)->text->beg + (buf)->text->gpt - 1) | |
138 | |
139 /* Address of end of buffer. */ | |
140 #define BUF_Z_ADDR(buf) ((buf)->text->beg + (buf)->text->gap_size + (buf)->text->z - 1) | |
132 | 141 |
133 /* Macro for setting the value of BUF_ZV (BUF) to VALUE, | 142 /* Macro for setting the value of BUF_ZV (BUF) to VALUE, |
134 by varying the end of the accessible region. */ | 143 by varying the end of the accessible region. */ |
135 #define SET_BUF_ZV(buf, value) ((buf)->zv = (value)) | 144 #define SET_BUF_ZV(buf, value) ((buf)->zv = (value)) |
136 #define SET_BUF_PT(buf, value) ((buf)->pt = (value)) | 145 #define SET_BUF_PT(buf, value) ((buf)->pt = (value)) |
301 Lisp_Object keymap; | 310 Lisp_Object keymap; |
302 /* This buffer's local abbrev table. */ | 311 /* This buffer's local abbrev table. */ |
303 Lisp_Object abbrev_table; | 312 Lisp_Object abbrev_table; |
304 /* This buffer's syntax table. */ | 313 /* This buffer's syntax table. */ |
305 Lisp_Object syntax_table; | 314 Lisp_Object syntax_table; |
315 /* This buffer's category table. */ | |
316 Lisp_Object category_table; | |
306 | 317 |
307 /* Values of several buffer-local variables */ | 318 /* Values of several buffer-local variables */ |
308 /* tab-width is buffer-local so that redisplay can find it | 319 /* tab-width is buffer-local so that redisplay can find it |
309 in buffers that are not current */ | 320 in buffers that are not current */ |
310 Lisp_Object case_fold_search; | 321 Lisp_Object case_fold_search; |
313 Lisp_Object left_margin; | 324 Lisp_Object left_margin; |
314 /* Function to call when insert space past fill column. */ | 325 /* Function to call when insert space past fill column. */ |
315 Lisp_Object auto_fill_function; | 326 Lisp_Object auto_fill_function; |
316 /* nil: text, t: binary. | 327 /* nil: text, t: binary. |
317 This value is meaningful only on certain operating systems. */ | 328 This value is meaningful only on certain operating systems. */ |
329 /* Actually, we don't need this flag any more because end-of-line | |
330 is handled correctly according to the buffer-file-coding-system | |
331 of the buffer. Just keeping it for backward compatibility. */ | |
318 Lisp_Object buffer_file_type; | 332 Lisp_Object buffer_file_type; |
319 | 333 |
320 /* Case table for case-conversion in this buffer. | 334 /* Case table for case-conversion in this buffer. |
321 This char-table maps each char into its lower-case version. */ | 335 This char-table maps each char into its lower-case version. */ |
322 Lisp_Object downcase_table; | 336 Lisp_Object downcase_table; |
329 | 343 |
330 /* Non-nil means do not display continuation lines. */ | 344 /* Non-nil means do not display continuation lines. */ |
331 Lisp_Object truncate_lines; | 345 Lisp_Object truncate_lines; |
332 /* Non-nil means display ctl chars with uparrow. */ | 346 /* Non-nil means display ctl chars with uparrow. */ |
333 Lisp_Object ctl_arrow; | 347 Lisp_Object ctl_arrow; |
348 /* Non-nil means display text from right to left. */ | |
349 Lisp_Object direction_reversed; | |
334 /* Non-nil means do selective display; | 350 /* Non-nil means do selective display; |
335 see doc string in syms_of_buffer (buffer.c) for details. */ | 351 see doc string in syms_of_buffer (buffer.c) for details. */ |
336 Lisp_Object selective_display; | 352 Lisp_Object selective_display; |
337 #ifndef old | 353 #ifndef old |
338 /* Non-nil means show ... at end of line followed by invisible lines. */ | 354 /* Non-nil means show ... at end of line followed by invisible lines. */ |
367 Lisp_Object overlays_after; | 383 Lisp_Object overlays_after; |
368 | 384 |
369 /* Position where the overlay lists are centered. */ | 385 /* Position where the overlay lists are centered. */ |
370 Lisp_Object overlay_center; | 386 Lisp_Object overlay_center; |
371 | 387 |
388 /* Non-nil means the buffer contents are regarded as multi-byte | |
389 form of characters, not a binary code. */ | |
390 Lisp_Object enable_multibyte_characters; | |
391 | |
372 /* List of symbols naming the file format used for visited file. */ | 392 /* List of symbols naming the file format used for visited file. */ |
373 Lisp_Object file_format; | 393 Lisp_Object file_format; |
374 | 394 |
375 /* True if the newline position cache and width run cache are | 395 /* True if the newline position cache and width run cache are |
376 enabled. See search.c and indent.c. */ | 396 enabled. See search.c and indent.c. */ |
466 | 486 |
467 /* Point in the current buffer. This is an obsolete alias | 487 /* Point in the current buffer. This is an obsolete alias |
468 and should be eliminated. */ | 488 and should be eliminated. */ |
469 #define point (current_buffer->pt + 0) | 489 #define point (current_buffer->pt + 0) |
470 | 490 |
471 /* Return character at position n. No range checking. */ | 491 /* Return the address of position N. No range checking. */ |
472 #define FETCH_CHAR(n) *(((n)>= GPT ? GAP_SIZE : 0) + (n) + BEG_ADDR - 1) | 492 #define POS_ADDR(n) (((n)>= GPT ? GAP_SIZE : 0) + (n) + BEG_ADDR - 1) |
493 | |
494 /* Return the byte at position N. No range checking. */ | |
495 #define FETCH_BYTE(n) *(POS_ADDR ((n))) | |
496 | |
497 /* Variables used locally in FETCH_MULTIBYTE_CHAR. */ | |
498 extern unsigned char *_fetch_multibyte_char_p; | |
499 extern int _fetch_multibyte_char_len; | |
500 | |
501 /* Return character code of multi-byte form at position POS. If POS | |
502 doesn't point the head of valid multi-byte form, only the byte at | |
503 POS is returned. No range checking. */ | |
504 | |
505 #define FETCH_MULTIBYTE_CHAR(pos) \ | |
506 (_fetch_multibyte_char_p = (((pos) >= GPT ? GAP_SIZE : 0) \ | |
507 + (pos) + BEG_ADDR - 1), \ | |
508 _fetch_multibyte_char_len = ((pos) >= GPT ? ZV : GPT) - (pos), \ | |
509 STRING_CHAR (_fetch_multibyte_char_p, _fetch_multibyte_char_len)) | |
510 | |
511 /* Return character at position POS. No range checking. */ | |
512 #define FETCH_CHAR(pos) \ | |
513 (!NILP (current_buffer->enable_multibyte_characters) \ | |
514 ? FETCH_MULTIBYTE_CHAR ((pos)) \ | |
515 : FETCH_BYTE ((pos))) | |
473 | 516 |
474 /* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return | 517 /* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return |
475 the max (resp. min) p such that | 518 the max (resp. min) p such that |
476 | 519 |
477 &FETCH_CHAR (p) - &FETCH_CHAR (n) == p - n */ | 520 POS_ADDR (p) - POS_ADDR (n) == p - n */ |
478 | 521 |
479 #define BUFFER_CEILING_OF(n) (((n) < GPT && GPT < ZV ? GPT : ZV) - 1) | 522 #define BUFFER_CEILING_OF(n) (((n) < GPT && GPT < ZV ? GPT : ZV) - 1) |
480 #define BUFFER_FLOOR_OF(n) (BEGV <= GPT && GPT <= (n) ? GPT : BEGV) | 523 #define BUFFER_FLOOR_OF(n) (BEGV <= GPT && GPT <= (n) ? GPT : BEGV) |
481 | 524 |
482 extern void reset_buffer (); | 525 extern void reset_buffer (); |