ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvt.h
(Generate patch)

Comparing rxvt-unicode/src/rxvt.h (file contents):
Revision 1.556 by sf-exg, Thu May 13 19:40:19 2021 UTC vs.
Revision 1.563 by sf-exg, Sat Jun 19 09:13:51 2021 UTC

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.
792struct compose_char 792struct compose_char
793{ 793{
794 unicode_t c1, c2; // any chars != NOCHAR are valid 794 // c1 can be any character != NOCHAR, including another compose character
795 // c2 must always be a zero-width character or NOCHAR, in case
796 // this just extends beyond the 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};
800 803
801class rxvt_composite_vec 804struct rxvt_composite_vec
802{ 805{
803 vector<compose_char> v; 806 vector<compose_char> v;
804public: 807
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;
812 } 816 }
813}; 817};
814 818
815extern class rxvt_composite_vec rxvt_composite; 819extern class rxvt_composite_vec rxvt_composite;
816#endif 820#endif
821
822// expand the sequence into a static array
823// works even without ENABLE_COMBINING
824template<typename T, int max_size_ = 48>
825struct 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};
817 878
818/****************************************************************************/ 879/****************************************************************************/
819 880
820#ifdef KEYSYM_RESOURCE 881#ifdef KEYSYM_RESOURCE
821class keyboard_manager; 882class keyboard_manager;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines