… | |
… | |
769 | /****************************************************************************/ |
769 | /****************************************************************************/ |
770 | |
770 | |
771 | #define UNICODE_MASK 0x1fffffUL |
771 | #define UNICODE_MASK 0x1fffffUL |
772 | |
772 | |
773 | #if UNICODE_3 |
773 | #if UNICODE_3 |
774 | # define COMPOSE_LO 0x40000000UL |
774 | # define COMPOSE_LO 0x110000UL |
775 | # define COMPOSE_HI 0x400fffffUL |
775 | # define COMPOSE_HI 0x1fffffUL |
776 | # define IS_COMPOSE(n) ((int32_t)(n) >= COMPOSE_LO) |
776 | # define IS_COMPOSE(n) ((int32_t)(n) >= COMPOSE_LO) |
777 | #else |
777 | #else |
778 | # if ENABLE_PERL |
778 | # if ENABLE_PERL |
779 | # define COMPOSE_LO 0xe000UL // our _own_ functions don't like (illegal) surrogates |
779 | # define COMPOSE_LO 0xe000UL // our _own_ functions don't like (illegal) surrogates |
780 | # define COMPOSE_HI 0xf8ffUL // in utf-8, so use private use area only |
780 | # define COMPOSE_HI 0xf8ffUL // in utf-8, so use private use area only |
… | |
… | |
789 | // compose chars are used to represent composite characters |
789 | // compose chars are used to represent composite characters |
790 | // that are not representable in unicode, as well as characters |
790 | // that are not representable in unicode, as well as characters |
791 | // not fitting in the BMP. |
791 | // not fitting in the BMP. |
792 | struct compose_char |
792 | struct compose_char |
793 | { |
793 | { |
794 | unicode_t c1, c2; // any chars != NOCHAR are valid |
794 | // c1 can be any chaarcter != NOCHAR, including another compose character |
|
|
795 | // c2 must always be a zero-width character or NOCHAR, in case |
|
|
796 | // this just extends beyondthe BMP. |
|
|
797 | unicode_t c1, c2; |
795 | |
798 | |
796 | compose_char (unicode_t c1, unicode_t c2) |
799 | compose_char (unicode_t c1, unicode_t c2) |
797 | : c1(c1), c2(c2) |
800 | : c1(c1), c2(c2) |
798 | { } |
801 | { } |
799 | }; |
802 | }; |
… | |
… | |
801 | class rxvt_composite_vec |
804 | class rxvt_composite_vec |
802 | { |
805 | { |
803 | vector<compose_char> v; |
806 | vector<compose_char> v; |
804 | public: |
807 | public: |
805 | text_t compose (unicode_t c1, unicode_t c2 = NOCHAR); |
808 | text_t compose (unicode_t c1, unicode_t c2 = NOCHAR); |
806 | int expand (unicode_t c, wchar_t *r); |
809 | template<typename T> int expand (unicode_t c, T *r); |
|
|
810 | int expand (unicode_t c) { return expand (c, (text_t *)0); } |
807 | compose_char *operator [](text_t c) |
811 | compose_char *operator [](text_t c) |
808 | { |
812 | { |
809 | return c >= COMPOSE_LO && c < COMPOSE_LO + v.size () |
813 | return c >= COMPOSE_LO && c < COMPOSE_LO + v.size () |
810 | ? &v[c - COMPOSE_LO] |
814 | ? &v[c - COMPOSE_LO] |
811 | : 0; |
815 | : 0; |