diff options
| author | Kim F. Storm | 2008-02-27 22:49:15 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2008-02-27 22:49:15 +0000 |
| commit | ec9ed378f4fb5adf306064fe8c3f5e512e45b6c4 (patch) | |
| tree | b49c9397b28da6db0f0abdda55571ae4d371fe67 /src | |
| parent | f59836fede1fd5e29de705d9227473e2ab909079 (diff) | |
| download | emacs-ec9ed378f4fb5adf306064fe8c3f5e512e45b6c4.tar.gz emacs-ec9ed378f4fb5adf306064fe8c3f5e512e45b6c4.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lisp.h | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/src/lisp.h b/src/lisp.h index a460b89c326..bf39ff0e08f 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1424,43 +1424,54 @@ typedef unsigned char UCHAR; | |||
| 1424 | #define KEY_DESCRIPTION_SIZE ((2 * 6) + 1 + (CHARACTERBITS / 3) + 1 + 1) | 1424 | #define KEY_DESCRIPTION_SIZE ((2 * 6) + 1 + (CHARACTERBITS / 3) + 1 + 1) |
| 1425 | 1425 | ||
| 1426 | 1426 | ||
| 1427 | /* The glyph datatype, used to represent characters on the display. */ | 1427 | /* The glyph datatype, used to represent characters on the display. |
| 1428 | 1428 | It consists of a char code and a face id. */ | |
| 1429 | /* Glyph code to use as an index to the glyph table. If it is out of | 1429 | |
| 1430 | range for the glyph table, or the corresonding element in the table | 1430 | typedef struct { |
| 1431 | is nil, the low 8 bits are the single byte character code, and the | 1431 | int ch; |
| 1432 | bits above are the numeric face ID. If FID is the face ID of a | 1432 | int face_id; |
| 1433 | glyph on a frame F, then F->display.x->faces[FID] contains the | 1433 | } GLYPH; |
| 1434 | description of that face. This is an int instead of a short, so we | ||
| 1435 | can support a good bunch of face ID's (2^(31 - 8)); given that we | ||
| 1436 | have no mechanism for tossing unused frame face ID's yet, we'll | ||
| 1437 | probably run out of 255 pretty quickly. | ||
| 1438 | This is always -1 for a multibyte character. */ | ||
| 1439 | #define GLYPH int | ||
| 1440 | |||
| 1441 | /* Mask bits for face. */ | ||
| 1442 | #define GLYPH_MASK_FACE 0x7FC00000 | ||
| 1443 | /* Mask bits for character code. */ | ||
| 1444 | #define GLYPH_MASK_CHAR 0x003FFFFF /* The lowest 22 bits */ | ||
| 1445 | |||
| 1446 | /* The FAST macros assume that we already know we're in an X window. */ | ||
| 1447 | |||
| 1448 | /* Set a character code and a face ID in a glyph G. */ | ||
| 1449 | #define FAST_MAKE_GLYPH(char, face) ((char) | ((face) << CHARACTERBITS)) | ||
| 1450 | 1434 | ||
| 1451 | /* Return a glyph's character code. */ | 1435 | /* Return a glyph's character code. */ |
| 1452 | #define FAST_GLYPH_CHAR(glyph) ((glyph) & GLYPH_MASK_CHAR) | 1436 | #define GLYPH_CHAR(glyph) ((glyph).ch) |
| 1453 | 1437 | ||
| 1454 | /* Return a glyph's face ID. */ | 1438 | /* Return a glyph's face ID. */ |
| 1455 | #define FAST_GLYPH_FACE(glyph) (((glyph) & GLYPH_MASK_FACE) >> CHARACTERBITS) | 1439 | #define GLYPH_FACE(glyph) ((glyph).face_id) |
| 1456 | 1440 | ||
| 1457 | /* Slower versions that test the frame type first. */ | 1441 | #define SET_GLYPH_CHAR(glyph, char) ((glyph).ch = (char)) |
| 1458 | #define MAKE_GLYPH(f, char, face) (FAST_MAKE_GLYPH (char, face)) | 1442 | #define SET_GLYPH_FACE(glyph, face) ((glyph).face_id = (face)) |
| 1459 | #define GLYPH_CHAR(f, g) (FAST_GLYPH_CHAR (g)) | 1443 | #define SET_GLYPH(glyph, char, face) ((glyph).ch = (char), (glyph).face_id = (face)) |
| 1460 | #define GLYPH_FACE(f, g) (FAST_GLYPH_FACE (g)) | ||
| 1461 | 1444 | ||
| 1462 | /* Return 1 if GLYPH contains valid character code. */ | 1445 | /* Return 1 if GLYPH contains valid character code. */ |
| 1463 | #define GLYPH_CHAR_VALID_P(glyph) CHAR_VALID_P (FAST_GLYPH_CHAR (glyph), 1) | 1446 | #define GLYPH_CHAR_VALID_P(glyph) CHAR_VALID_P (GLYPH_CHAR (glyph), 1) |
| 1447 | |||
| 1448 | |||
| 1449 | /* Glyph Code from a display vector may either be an integer which | ||
| 1450 | encodes a char code in the lower CHARACTERBITS bits and a (very small) | ||
| 1451 | face-id in the upper bits, or it may be a cons (CHAR . FACE-ID). */ | ||
| 1452 | |||
| 1453 | #define GLYPH_CODE_CHAR(gc) \ | ||
| 1454 | (CONSP (gc) ? XINT (XCAR (gc)) : INTEGERP (gc) ? (XINT (gc) & ((1 << CHARACTERBITS)-1)) : 0) | ||
| 1455 | |||
| 1456 | #define GLYPH_CODE_FACE(gc) \ | ||
| 1457 | (CONSP (gc) ? XINT (XCDR (gc)) : INTEGERP (gc) ? (XINT (gc) >> CHARACTERBITS) : DEFAULT_FACE_ID) | ||
| 1458 | |||
| 1459 | /* Return 1 if glyph code from display vector contains valid character code. */ | ||
| 1460 | #define GLYPH_CODE_CHAR_VALID_P(gc) CHAR_VALID_P (GLYPH_CODE_CHAR (gc), 1) | ||
| 1461 | |||
| 1462 | #define GLYPH_CODE_P(gc) ((CONSP (gc) && INTEGERP (XCAR (gc)) && INTEGERP (XCDR (gc))) || INTEGERP (gc)) | ||
| 1463 | |||
| 1464 | /* Only called when GLYPH_CODE_P (gc) is true. */ | ||
| 1465 | #define SET_GLYPH_FROM_GLYPH_CODE(glyph, gc) \ | ||
| 1466 | do \ | ||
| 1467 | { \ | ||
| 1468 | if (CONSP (gc)) \ | ||
| 1469 | SET_GLYPH (glyph, XINT (XCAR (gc)), XINT (XCDR (gc))); \ | ||
| 1470 | else \ | ||
| 1471 | SET_GLYPH (glyph, (XINT (gc) & ((1 << CHARACTERBITS)-1)), \ | ||
| 1472 | (XINT (gc) >> CHARACTERBITS)); \ | ||
| 1473 | } \ | ||
| 1474 | while (0) | ||
| 1464 | 1475 | ||
| 1465 | /* The ID of the mode line highlighting face. */ | 1476 | /* The ID of the mode line highlighting face. */ |
| 1466 | #define GLYPH_MODE_LINE_FACE 1 | 1477 | #define GLYPH_MODE_LINE_FACE 1 |