Mercurial > emacs
changeset 92279:14182a83bd23
(GLYPH): Change type from int to struct with separate char
and face_id members.
(GLYPH_MASK_FACE, GLYPH_MASK_CHAR): Delete macros.
(GLYPH_CHAR, GLYPH_FACE): Remove slow versions with frame arg.
(FAST_GLYPH_CHAR, FAST_GLYPH_FACE): Rename macros to ...
(GLYPH_CHAR, GLYPH_FACE): ... these. Change users.
(FAST_MAKE_GLYPH, MAKE_GLYPH): Remove. Rewrite users to use ...
(SET_GLYPH, SET_GLYPH_CHAR, SET_GLYPH_FACE): ... these macros instead.
(GLYPH_CODE_CHAR, GLYPH_CODE_FACE, GLYPH_CODE_P)
(GLYPH_CODE_CHAR_VALID_P, SET_GLYPH_FROM_GLYPH_CODE): New macros to
handle new Lisp glyph code encoding, either an integer or a cons.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Wed, 27 Feb 2008 22:49:15 +0000 |
parents | ec0a63595f5b |
children | 48b836154530 |
files | src/lisp.h |
diffstat | 1 files changed, 42 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lisp.h Wed Feb 27 22:49:07 2008 +0000 +++ b/src/lisp.h Wed Feb 27 22:49:15 2008 +0000 @@ -1424,43 +1424,54 @@ #define KEY_DESCRIPTION_SIZE ((2 * 6) + 1 + (CHARACTERBITS / 3) + 1 + 1) -/* The glyph datatype, used to represent characters on the display. */ - -/* Glyph code to use as an index to the glyph table. If it is out of - range for the glyph table, or the corresonding element in the table - is nil, the low 8 bits are the single byte character code, and the - bits above are the numeric face ID. If FID is the face ID of a - glyph on a frame F, then F->display.x->faces[FID] contains the - description of that face. This is an int instead of a short, so we - can support a good bunch of face ID's (2^(31 - 8)); given that we - have no mechanism for tossing unused frame face ID's yet, we'll - probably run out of 255 pretty quickly. - This is always -1 for a multibyte character. */ -#define GLYPH int - -/* Mask bits for face. */ -#define GLYPH_MASK_FACE 0x7FC00000 - /* Mask bits for character code. */ -#define GLYPH_MASK_CHAR 0x003FFFFF /* The lowest 22 bits */ - -/* The FAST macros assume that we already know we're in an X window. */ - -/* Set a character code and a face ID in a glyph G. */ -#define FAST_MAKE_GLYPH(char, face) ((char) | ((face) << CHARACTERBITS)) +/* The glyph datatype, used to represent characters on the display. + It consists of a char code and a face id. */ + +typedef struct { + int ch; + int face_id; +} GLYPH; /* Return a glyph's character code. */ -#define FAST_GLYPH_CHAR(glyph) ((glyph) & GLYPH_MASK_CHAR) +#define GLYPH_CHAR(glyph) ((glyph).ch) /* Return a glyph's face ID. */ -#define FAST_GLYPH_FACE(glyph) (((glyph) & GLYPH_MASK_FACE) >> CHARACTERBITS) - -/* Slower versions that test the frame type first. */ -#define MAKE_GLYPH(f, char, face) (FAST_MAKE_GLYPH (char, face)) -#define GLYPH_CHAR(f, g) (FAST_GLYPH_CHAR (g)) -#define GLYPH_FACE(f, g) (FAST_GLYPH_FACE (g)) +#define GLYPH_FACE(glyph) ((glyph).face_id) + +#define SET_GLYPH_CHAR(glyph, char) ((glyph).ch = (char)) +#define SET_GLYPH_FACE(glyph, face) ((glyph).face_id = (face)) +#define SET_GLYPH(glyph, char, face) ((glyph).ch = (char), (glyph).face_id = (face)) /* Return 1 if GLYPH contains valid character code. */ -#define GLYPH_CHAR_VALID_P(glyph) CHAR_VALID_P (FAST_GLYPH_CHAR (glyph), 1) +#define GLYPH_CHAR_VALID_P(glyph) CHAR_VALID_P (GLYPH_CHAR (glyph), 1) + + +/* Glyph Code from a display vector may either be an integer which + encodes a char code in the lower CHARACTERBITS bits and a (very small) + face-id in the upper bits, or it may be a cons (CHAR . FACE-ID). */ + +#define GLYPH_CODE_CHAR(gc) \ + (CONSP (gc) ? XINT (XCAR (gc)) : INTEGERP (gc) ? (XINT (gc) & ((1 << CHARACTERBITS)-1)) : 0) + +#define GLYPH_CODE_FACE(gc) \ + (CONSP (gc) ? XINT (XCDR (gc)) : INTEGERP (gc) ? (XINT (gc) >> CHARACTERBITS) : DEFAULT_FACE_ID) + +/* Return 1 if glyph code from display vector contains valid character code. */ +#define GLYPH_CODE_CHAR_VALID_P(gc) CHAR_VALID_P (GLYPH_CODE_CHAR (gc), 1) + +#define GLYPH_CODE_P(gc) ((CONSP (gc) && INTEGERP (XCAR (gc)) && INTEGERP (XCDR (gc))) || INTEGERP (gc)) + +/* Only called when GLYPH_CODE_P (gc) is true. */ +#define SET_GLYPH_FROM_GLYPH_CODE(glyph, gc) \ + do \ + { \ + if (CONSP (gc)) \ + SET_GLYPH (glyph, XINT (XCAR (gc)), XINT (XCDR (gc))); \ + else \ + SET_GLYPH (glyph, (XINT (gc) & ((1 << CHARACTERBITS)-1)), \ + (XINT (gc) >> CHARACTERBITS)); \ + } \ + while (0) /* The ID of the mode line highlighting face. */ #define GLYPH_MODE_LINE_FACE 1