… | |
… | |
791 | // not fitting in the BMP. |
791 | // not fitting in the BMP. |
792 | struct compose_char |
792 | struct compose_char |
793 | { |
793 | { |
794 | // c1 can be any chaarcter != NOCHAR, including another compose character |
794 | // c1 can be any chaarcter != NOCHAR, including another compose character |
795 | // c2 must always be a zero-width character or NOCHAR, in case |
795 | // c2 must always be a zero-width character or NOCHAR, in case |
796 | // this just extends beyondthe BMP. |
796 | // this just extends beyond the BMP. |
797 | unicode_t c1, c2; |
797 | unicode_t c1, c2; |
798 | |
798 | |
799 | compose_char (unicode_t c1, unicode_t c2) |
799 | compose_char (unicode_t c1, unicode_t c2) |
800 | : c1(c1), c2(c2) |
800 | : c1(c1), c2(c2) |
801 | { } |
801 | { } |
802 | }; |
802 | }; |
803 | |
803 | |
804 | class rxvt_composite_vec |
804 | struct rxvt_composite_vec |
805 | { |
805 | { |
806 | vector<compose_char> v; |
806 | vector<compose_char> v; |
807 | public: |
807 | |
808 | text_t compose (unicode_t c1, unicode_t c2 = NOCHAR); |
808 | text_t compose (unicode_t c1, unicode_t c2 = NOCHAR); |
809 | template<typename T> int expand (unicode_t c, 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); } |
810 | int expand (unicode_t c) { return expand (c, (text_t *)0); } |
811 | compose_char *operator [](text_t c) |
811 | compose_char *operator [](text_t c) |
812 | { |
812 | { |
… | |
… | |
816 | } |
816 | } |
817 | }; |
817 | }; |
818 | |
818 | |
819 | extern class rxvt_composite_vec rxvt_composite; |
819 | extern class rxvt_composite_vec rxvt_composite; |
820 | #endif |
820 | #endif |
|
|
821 | |
|
|
822 | // expand the sequence into a static array |
|
|
823 | // works even without ENABLE_COMBINING |
|
|
824 | template<typename T, int max_size_ = 48> |
|
|
825 | struct rxvt_compose_expand_static |
|
|
826 | { |
|
|
827 | #if ENABLE_COMBINING |
|
|
828 | enum { max_size = max_size_ }; |
|
|
829 | |
|
|
830 | T chrs[max_size]; |
|
|
831 | |
|
|
832 | // expand sequence and return start ptr |
|
|
833 | // guarantees at least one output |
|
|
834 | // get the length with length () on that ptr |
|
|
835 | T *operator ()(unicode_t c) |
|
|
836 | { |
|
|
837 | T *cur = chrs + max_size; |
|
|
838 | |
|
|
839 | while (ecb_expect_false (IS_COMPOSE (c))) |
|
|
840 | if (ecb_expect_true (c - COMPOSE_LO < rxvt_composite.v.size ())) |
|
|
841 | { |
|
|
842 | compose_char *cc = &rxvt_composite.v [c - COMPOSE_LO]; |
|
|
843 | |
|
|
844 | if (cc->c2 != NOCHAR) |
|
|
845 | { |
|
|
846 | cur -= cur > chrs; *cur = cc->c2; |
|
|
847 | } |
|
|
848 | |
|
|
849 | c = cc->c1; |
|
|
850 | } |
|
|
851 | else |
|
|
852 | c = NOCHAR; |
|
|
853 | |
|
|
854 | cur -= cur > chrs; *cur = c; |
|
|
855 | |
|
|
856 | return cur; |
|
|
857 | } |
|
|
858 | |
|
|
859 | int length (T *first) |
|
|
860 | { |
|
|
861 | return chrs + max_size - first; |
|
|
862 | } |
|
|
863 | #else |
|
|
864 | T chr; |
|
|
865 | |
|
|
866 | T *operator ()(text_t c); |
|
|
867 | { |
|
|
868 | chr = c; |
|
|
869 | return &chr; |
|
|
870 | } |
|
|
871 | |
|
|
872 | int length (T *first) |
|
|
873 | { |
|
|
874 | return 1; |
|
|
875 | } |
|
|
876 | #endif |
|
|
877 | }; |
821 | |
878 | |
822 | /****************************************************************************/ |
879 | /****************************************************************************/ |
823 | |
880 | |
824 | #ifdef KEYSYM_RESOURCE |
881 | #ifdef KEYSYM_RESOURCE |
825 | class keyboard_manager; |
882 | class keyboard_manager; |