diff options
| author | Karl Heuer | 1997-02-20 06:45:13 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-02-20 06:45:13 +0000 |
| commit | 96b65d4ea9e5994d8cee4c2fbf2246cf56c11039 (patch) | |
| tree | 345e01bb91e56839475f3a2ad6935f51acc1ae36 /src | |
| parent | 3b06f8809cce0dcd6e8ae9a05a2fbeb3712c4bcc (diff) | |
| download | emacs-96b65d4ea9e5994d8cee4c2fbf2246cf56c11039.tar.gz emacs-96b65d4ea9e5994d8cee4c2fbf2246cf56c11039.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.h | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/src/buffer.h b/src/buffer.h index 76e8c84b543..21f32422599 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -70,10 +70,10 @@ Boston, MA 02111-1307, USA. */ | |||
| 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) |
| @@ -82,7 +82,10 @@ Boston, MA 02111-1307, USA. */ | |||
| 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) |
| @@ -130,6 +133,12 @@ Boston, MA 02111-1307, USA. */ | |||
| 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) |
| 132 | 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) | ||
| 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)) |
| @@ -303,6 +312,8 @@ struct buffer | |||
| 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 |
| @@ -315,6 +326,9 @@ struct buffer | |||
| 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. |
| @@ -331,6 +345,8 @@ struct buffer | |||
| 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; |
| @@ -369,6 +385,10 @@ struct buffer | |||
| 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 | ||
| @@ -468,13 +488,36 @@ extern struct buffer buffer_local_types; | |||
| 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) |