… | |
… | |
23 | #if HAVE_WCHAR_H |
23 | #if HAVE_WCHAR_H |
24 | # include <wchar.h> |
24 | # include <wchar.h> |
25 | #else |
25 | #else |
26 | // stdlib.h might provide it |
26 | // stdlib.h might provide it |
27 | #endif |
27 | #endif |
|
|
28 | |
|
|
29 | #include <libptytty.h> |
28 | |
30 | |
29 | // we assume that Xlib.h defines XPointer, and it does since at least 1994... |
31 | // we assume that Xlib.h defines XPointer, and it does since at least 1994... |
30 | |
32 | |
31 | extern "C" { |
33 | extern "C" { |
32 | #include <X11/Xlib.h> |
34 | #include <X11/Xlib.h> |
… | |
… | |
88 | #include "rxvtfont.h" |
90 | #include "rxvtfont.h" |
89 | #include "rxvttoolkit.h" |
91 | #include "rxvttoolkit.h" |
90 | #include "rxvtimg.h" |
92 | #include "rxvtimg.h" |
91 | #include "scrollbar.h" |
93 | #include "scrollbar.h" |
92 | #include "ev_cpp.h" |
94 | #include "ev_cpp.h" |
93 | #include "libptytty.h" |
|
|
94 | |
95 | |
95 | #include "rxvtperl.h" |
96 | #include "rxvtperl.h" |
96 | |
97 | |
97 | // try to avoid some macros to decrease code size, on some systems |
98 | // try to avoid some macros to decrease code size, on some systems |
98 | #if ENABLE_MINIMAL |
99 | #if ENABLE_MINIMAL |
… | |
… | |
123 | #endif |
124 | #endif |
124 | |
125 | |
125 | /****************************************************************************/ |
126 | /****************************************************************************/ |
126 | |
127 | |
127 | // exception thrown on fatal (per-instance) errors |
128 | // exception thrown on fatal (per-instance) errors |
128 | class rxvt_failure_exception { }; |
129 | class rxvt_failure_exception : public std::exception |
|
|
130 | { |
|
|
131 | public: |
|
|
132 | const char * |
|
|
133 | what () const noexcept override |
|
|
134 | { |
|
|
135 | return ""; |
|
|
136 | } |
|
|
137 | }; |
129 | |
138 | |
130 | // exception thrown when the command parser runs out of input data |
139 | // exception thrown when the command parser runs out of input data |
131 | class out_of_input { }; |
140 | class out_of_input { }; |
132 | |
141 | |
133 | /* |
142 | /* |
… | |
… | |
769 | /****************************************************************************/ |
778 | /****************************************************************************/ |
770 | |
779 | |
771 | #define UNICODE_MASK 0x1fffffUL |
780 | #define UNICODE_MASK 0x1fffffUL |
772 | |
781 | |
773 | #if UNICODE_3 |
782 | #if UNICODE_3 |
774 | # define COMPOSE_LO 0x40000000UL |
783 | # define COMPOSE_LO 0x110000UL |
775 | # define COMPOSE_HI 0x400fffffUL |
784 | # define COMPOSE_HI 0x1fffffUL |
776 | # define IS_COMPOSE(n) ((int32_t)(n) >= COMPOSE_LO) |
785 | # define IS_COMPOSE(n) ((int32_t)(n) >= COMPOSE_LO) |
777 | #else |
786 | #else |
778 | # if ENABLE_PERL |
787 | # if ENABLE_PERL |
779 | # define COMPOSE_LO 0xe000UL // our _own_ functions don't like (illegal) surrogates |
788 | # 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 |
789 | # define COMPOSE_HI 0xf8ffUL // in utf-8, so use private use area only |
… | |
… | |
789 | // compose chars are used to represent composite characters |
798 | // compose chars are used to represent composite characters |
790 | // that are not representable in unicode, as well as characters |
799 | // that are not representable in unicode, as well as characters |
791 | // not fitting in the BMP. |
800 | // not fitting in the BMP. |
792 | struct compose_char |
801 | struct compose_char |
793 | { |
802 | { |
794 | unicode_t c1, c2; // any chars != NOCHAR are valid |
803 | // c1 can be any character != NOCHAR, including another compose character |
|
|
804 | // c2 must always be a zero-width character or NOCHAR, in case |
|
|
805 | // this just extends beyond the BMP. |
|
|
806 | unicode_t c1, c2; |
795 | |
807 | |
796 | compose_char (unicode_t c1, unicode_t c2) |
808 | compose_char (unicode_t c1, unicode_t c2) |
797 | : c1(c1), c2(c2) |
809 | : c1(c1), c2(c2) |
798 | { } |
810 | { } |
799 | }; |
811 | }; |
800 | |
812 | |
801 | class rxvt_composite_vec |
813 | struct rxvt_composite_vec |
802 | { |
814 | { |
803 | vector<compose_char> v; |
815 | vector<compose_char> v; |
804 | public: |
816 | |
805 | text_t compose (unicode_t c1, unicode_t c2 = NOCHAR); |
817 | text_t compose (unicode_t c1, unicode_t c2 = NOCHAR); |
806 | int expand (unicode_t c, wchar_t *r); |
818 | template<typename T> int expand (unicode_t c, T *r); |
|
|
819 | int expand (unicode_t c) { return expand (c, (text_t *)0); } |
807 | compose_char *operator [](text_t c) |
820 | compose_char *operator [](text_t c) |
808 | { |
821 | { |
809 | return c >= COMPOSE_LO && c < COMPOSE_LO + v.size () |
822 | return c >= COMPOSE_LO && c < COMPOSE_LO + v.size () |
810 | ? &v[c - COMPOSE_LO] |
823 | ? &v[c - COMPOSE_LO] |
811 | : 0; |
824 | : 0; |
812 | } |
825 | } |
813 | }; |
826 | }; |
814 | |
827 | |
815 | extern class rxvt_composite_vec rxvt_composite; |
828 | extern class rxvt_composite_vec rxvt_composite; |
|
|
829 | #endif |
|
|
830 | |
|
|
831 | #if 0 |
|
|
832 | // expand the sequence into a static array |
|
|
833 | // works even without ENABLE_COMBINING |
|
|
834 | template<typename T, int max_size_ = 48> |
|
|
835 | struct rxvt_compose_expand_static |
|
|
836 | { |
|
|
837 | #if ENABLE_COMBINING |
|
|
838 | enum { max_size = max_size_ }; |
|
|
839 | |
|
|
840 | T chrs[max_size]; |
|
|
841 | |
|
|
842 | // expand sequence and return start ptr |
|
|
843 | // guarantees at least one output |
|
|
844 | // get the length with length () on that ptr |
|
|
845 | T *operator ()(unicode_t c) |
|
|
846 | { |
|
|
847 | T *cur = chrs + max_size; |
|
|
848 | |
|
|
849 | while (ecb_expect_false (IS_COMPOSE (c))) |
|
|
850 | if (ecb_expect_true (c - COMPOSE_LO < rxvt_composite.v.size ())) |
|
|
851 | { |
|
|
852 | compose_char *cc = &rxvt_composite.v [c - COMPOSE_LO]; |
|
|
853 | |
|
|
854 | if (cc->c2 != NOCHAR) |
|
|
855 | { |
|
|
856 | cur -= cur > chrs; *cur = cc->c2; |
|
|
857 | } |
|
|
858 | |
|
|
859 | c = cc->c1; |
|
|
860 | } |
|
|
861 | else |
|
|
862 | c = NOCHAR; |
|
|
863 | |
|
|
864 | cur -= cur > chrs; *cur = c; |
|
|
865 | |
|
|
866 | return cur; |
|
|
867 | } |
|
|
868 | |
|
|
869 | int length (T *first) |
|
|
870 | { |
|
|
871 | return chrs + max_size - first; |
|
|
872 | } |
|
|
873 | #else |
|
|
874 | T chr; |
|
|
875 | |
|
|
876 | T *operator ()(text_t c); |
|
|
877 | { |
|
|
878 | chr = c; |
|
|
879 | return &chr; |
|
|
880 | } |
|
|
881 | |
|
|
882 | int length (T *first) |
|
|
883 | { |
|
|
884 | return 1; |
|
|
885 | } |
|
|
886 | #endif |
|
|
887 | }; |
816 | #endif |
888 | #endif |
817 | |
889 | |
818 | /****************************************************************************/ |
890 | /****************************************************************************/ |
819 | |
891 | |
820 | #ifdef KEYSYM_RESOURCE |
892 | #ifdef KEYSYM_RESOURCE |
… | |
… | |
1029 | current_screen:1, /* primary or secondary */ |
1101 | current_screen:1, /* primary or secondary */ |
1030 | num_scr_allow:1, |
1102 | num_scr_allow:1, |
1031 | bypass_keystate:1, |
1103 | bypass_keystate:1, |
1032 | #if ENABLE_FRILLS |
1104 | #if ENABLE_FRILLS |
1033 | urgency_hint:1, |
1105 | urgency_hint:1, |
|
|
1106 | rewrap_always:1, |
|
|
1107 | rewrap_never:1, |
1034 | #endif |
1108 | #endif |
1035 | #if CURSOR_BLINK |
1109 | #if CURSOR_BLINK |
1036 | hidden_cursor:1, |
1110 | hidden_cursor:1, |
1037 | #endif |
1111 | #endif |
1038 | #if TEXT_BLINK |
1112 | #if TEXT_BLINK |