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.560 by root, Thu Jun 17 19:37:28 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 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};
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>
825struct 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};
817 880
818/****************************************************************************/ 881/****************************************************************************/
819 882
820#ifdef KEYSYM_RESOURCE 883#ifdef KEYSYM_RESOURCE
821class keyboard_manager; 884class keyboard_manager;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines