… | |
… | |
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> |
|
|
825 | struct rxvt_compose_expand_static |
|
|
826 | { |
|
|
827 | #if ENABLE_COMBINING |
|
|
828 | // we arbitrarily limit the maximum number of compose sequences |
|
|
829 | // so we can store them in a static array on the stack. |
|
|
830 | enum { max_size = 48 }; |
|
|
831 | |
|
|
832 | T chrs[max_size]; |
|
|
833 | |
|
|
834 | // expand sequence and return start ptr |
|
|
835 | // guarantees at least one output |
|
|
836 | // get the length with length () on that ptr |
|
|
837 | T *operator ()(unicode_t c) |
|
|
838 | { |
|
|
839 | T *cur = chrs + max_size; |
|
|
840 | |
|
|
841 | while (ecb_expect_false (IS_COMPOSE (c))) |
|
|
842 | if (ecb_expect_true (c - COMPOSE_LO < rxvt_composite.v.size ())) |
|
|
843 | { |
|
|
844 | compose_char *cc = &rxvt_composite.v [c - COMPOSE_LO]; |
|
|
845 | |
|
|
846 | if (cc->c2 != NOCHAR) |
|
|
847 | { |
|
|
848 | cur -= cur > chrs; *cur = cc->c2; |
|
|
849 | } |
|
|
850 | |
|
|
851 | c = cc->c1; |
|
|
852 | } |
|
|
853 | else |
|
|
854 | c = NOCHAR; |
|
|
855 | |
|
|
856 | cur -= cur > chrs; *cur = c; |
|
|
857 | |
|
|
858 | return cur; |
|
|
859 | } |
|
|
860 | |
|
|
861 | int length (T *first) |
|
|
862 | { |
|
|
863 | return chrs + max_size - first; |
|
|
864 | } |
|
|
865 | #else |
|
|
866 | T chr; |
|
|
867 | |
|
|
868 | T *operator ()(text_t c); |
|
|
869 | { |
|
|
870 | chr = c; |
|
|
871 | return &chr; |
|
|
872 | } |
|
|
873 | |
|
|
874 | int length (T *first) |
|
|
875 | { |
|
|
876 | return 1; |
|
|
877 | } |
|
|
878 | #endif |
|
|
879 | }; |
821 | |
880 | |
822 | /****************************************************************************/ |
881 | /****************************************************************************/ |
823 | |
882 | |
824 | #ifdef KEYSYM_RESOURCE |
883 | #ifdef KEYSYM_RESOURCE |
825 | class keyboard_manager; |
884 | class keyboard_manager; |