… | |
… | |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
6 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
7 | * - original version |
7 | * - original version |
8 | * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca> |
8 | * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca> |
9 | * Copyright (c) 2003-2006 Marc Lehmann <schmorp@schmorp.de> |
9 | * Copyright (c) 2003-2006 Marc Lehmann <schmorp@schmorp.de> |
10 | * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> |
10 | * Copyright (c) 2007,2015 Emanuele Giaquinta <e.giaquinta@glauco.it> |
11 | * |
11 | * |
12 | * This program is free software; you can redistribute it and/or modify |
12 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by |
13 | * it under the terms of the GNU General Public License as published by |
14 | * the Free Software Foundation; either version 3 of the License, or |
14 | * the Free Software Foundation; either version 3 of the License, or |
15 | * (at your option) any later version. |
15 | * (at your option) any later version. |
… | |
… | |
113 | STRG (Rs_scrollBar_thickness, "thickness", "sbt", "number", "scrollbar thickness/width in pixels"), |
113 | STRG (Rs_scrollBar_thickness, "thickness", "sbt", "number", "scrollbar thickness/width in pixels"), |
114 | BOOL (Rs_scrollTtyOutput, "scrollTtyOutput", NULL, Opt_scrollTtyOutput, 0, NULL), |
114 | BOOL (Rs_scrollTtyOutput, "scrollTtyOutput", NULL, Opt_scrollTtyOutput, 0, NULL), |
115 | BOOL (Rs_scrollTtyOutput, NULL, "si", Opt_scrollTtyOutput, Optflag_Reverse, "scroll-on-tty-output inhibit"), |
115 | BOOL (Rs_scrollTtyOutput, NULL, "si", Opt_scrollTtyOutput, Optflag_Reverse, "scroll-on-tty-output inhibit"), |
116 | BOOL (Rs_scrollTtyKeypress, "scrollTtyKeypress", "sk", Opt_scrollTtyKeypress, 0, "scroll-on-keypress"), |
116 | BOOL (Rs_scrollTtyKeypress, "scrollTtyKeypress", "sk", Opt_scrollTtyKeypress, 0, "scroll-on-keypress"), |
117 | BOOL (Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer, 0, "scroll-with-buffer"), |
117 | BOOL (Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer, 0, "scroll-with-buffer"), |
118 | #if BG_IMAGE_FROM_ROOT |
|
|
119 | BOOL (Rs_transparent, "inheritPixmap", "ip", Opt_transparent, 0, "inherit parent pixmap"), |
|
|
120 | BOOL (Rs_transparent, "transparent", "tr", Opt_transparent, 0, "inherit parent pixmap"), |
|
|
121 | STRG (Rs_color + Color_tint, "tintColor", "tint", "color", "tint color"), |
|
|
122 | STRG (Rs_shade, "shading", "sh", "number", "shade background by number %."), |
|
|
123 | STRG (Rs_blurradius, "blurRadius", "blr", "HxV", "gaussian blur radii to apply to the root background"), |
|
|
124 | #endif |
|
|
125 | #if OFF_FOCUS_FADING |
118 | #if OFF_FOCUS_FADING |
126 | STRG (Rs_fade, "fading", "fade", "number", "fade colors by number % when losing focus"), |
119 | STRG (Rs_fade, "fading", "fade", "number", "fade colors by number % when losing focus"), |
127 | STRG (Rs_color + Color_fade, "fadeColor", "fadecolor", "color", "target color for off-focus fading"), |
120 | STRG (Rs_color + Color_fade, "fadeColor", "fadecolor", "color", "target color for off-focus fading"), |
128 | #endif |
121 | #endif |
129 | BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, 0, "utmp inhibit"), |
122 | BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, 0, "utmp inhibit"), |
… | |
… | |
141 | #endif |
134 | #endif |
142 | #ifdef MOUSE_WHEEL |
135 | #ifdef MOUSE_WHEEL |
143 | BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, 0, NULL), |
136 | BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, 0, NULL), |
144 | #endif |
137 | #endif |
145 | #if ENABLE_FRILLS |
138 | #if ENABLE_FRILLS |
|
|
139 | BOOL (Rs_disablePasteBrackets, "disablePasteBrackets", "dpb", Opt_disablePasteBrackets, 0, "do not emit bracketed paste mode sequences"), |
146 | BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, 0, "triple click word selection"), |
140 | BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, 0, "triple click word selection"), |
147 | BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, 0, "enable possibly insecure escape sequences"), |
141 | BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, 0, "enable possibly insecure escape sequences"), |
148 | BOOL (Rs_cursorUnderline, "cursorUnderline", "uc", Opt_cursorUnderline, 0, "underline cursor"), |
142 | BOOL (Rs_cursorUnderline, "cursorUnderline", "uc", Opt_cursorUnderline, 0, "underline cursor"), |
149 | #endif |
143 | #endif |
150 | #if CURSOR_BLINK |
144 | #if CURSOR_BLINK |
… | |
… | |
194 | RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"), |
188 | RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"), |
195 | #endif /* NO_CURSORCOLOR */ |
189 | #endif /* NO_CURSORCOLOR */ |
196 | STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), |
190 | STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), |
197 | STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), |
191 | STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), |
198 | STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"), |
192 | STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"), |
199 | #if BG_IMAGE_FROM_FILE |
|
|
200 | RSTRG (Rs_path, "path", "search path"), |
|
|
201 | STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"), |
|
|
202 | #endif |
|
|
203 | #if ENABLE_EWMH |
193 | #if ENABLE_EWMH |
204 | STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), |
194 | STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), |
|
|
195 | #endif |
|
|
196 | #ifdef HAVE_XMU |
|
|
197 | RSTRG (Rs_pointerShape, "pointerShape", "string"), |
205 | #endif |
198 | #endif |
206 | /* fonts: command-line option = resource name */ |
199 | /* fonts: command-line option = resource name */ |
207 | STRG (Rs_font, "font", "fn", "fontname", "normal text font"), |
200 | STRG (Rs_font, "font", "fn", "fontname", "normal text font"), |
208 | #if ENABLE_STYLES |
201 | #if ENABLE_STYLES |
209 | STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"), |
202 | STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"), |
… | |
… | |
263 | RSTRG (Rs_answerbackstring, "answerbackString", "string"), |
256 | RSTRG (Rs_answerbackstring, "answerbackString", "string"), |
264 | #ifndef NO_SECONDARY_SCREEN |
257 | #ifndef NO_SECONDARY_SCREEN |
265 | BOOL (Rs_secondaryScreen, "secondaryScreen", "ssc", Opt_secondaryScreen, 0, "enable secondary screen"), |
258 | BOOL (Rs_secondaryScreen, "secondaryScreen", "ssc", Opt_secondaryScreen, 0, "enable secondary screen"), |
266 | BOOL (Rs_secondaryScroll, "secondaryScroll", "ssr", Opt_secondaryScroll, 0, "enable secondary screen scroll"), |
259 | BOOL (Rs_secondaryScroll, "secondaryScroll", "ssr", Opt_secondaryScroll, 0, "enable secondary screen scroll"), |
267 | #endif |
260 | #endif |
|
|
261 | #if ENABLE_FRILLS |
|
|
262 | STRG (Rs_rewrapMode, "rewrapMode", "rm", "string", "rewrap mode (auto, always, never)"), |
|
|
263 | #endif |
268 | #if ENABLE_PERL |
264 | #if ENABLE_PERL |
269 | RSTRG (Rs_perl_lib, "perl-lib", "string"), //, "colon-separated directories with extension scripts"),TODO |
265 | RSTRG (Rs_perl_lib, "perl-lib", "string"), //, "colon-separated directories with extension scripts"),TODO |
270 | RSTRG (Rs_perl_eval, "perl-eval", "perl-eval"), // "string", "code to be evaluated after all extensions have been loaded"),TODO |
266 | RSTRG (Rs_perl_eval, "perl-eval", "perl-eval"), // "string", "code to be evaluated after all extensions have been loaded"),TODO |
271 | RSTRG (Rs_perl_ext_1, "perl-ext-common", "string"), //, "colon-separated list of perl extensions to enable"),TODO |
267 | RSTRG (Rs_perl_ext_1, "perl-ext-common", "string"), //, "colon-separated list of perl extensions to enable"),TODO |
272 | STRG (Rs_perl_ext_2, "perl-ext", "pe", "string", "colon-separated list of perl extensions to enable for this instance"), |
268 | STRG (Rs_perl_ext_2, "perl-ext", "pe", "string", "colon-separated list of perl extensions to enable for this instance"), |
… | |
… | |
627 | |
623 | |
628 | /*}}} */ |
624 | /*}}} */ |
629 | |
625 | |
630 | /*----------------------------------------------------------------------*/ |
626 | /*----------------------------------------------------------------------*/ |
631 | |
627 | |
632 | # ifdef KEYSYM_RESOURCE |
628 | #ifdef KEYSYM_RESOURCE |
633 | static void |
629 | static void |
634 | rxvt_define_key (rxvt_term *term, const char *k, const char *v) |
630 | rxvt_define_key (rxvt_term *term, const char *k, const char *v) |
635 | { |
631 | { |
636 | term->bind_action (k, v); |
632 | term->bind_action (k, v); |
637 | } |
|
|
638 | |
|
|
639 | /* |
|
|
640 | * Define key from XrmEnumerateDatabase. |
|
|
641 | * quarks will be something like |
|
|
642 | * "rxvt" "keysym" "0xFF01" |
|
|
643 | * value will be a string |
|
|
644 | */ |
|
|
645 | static int |
|
|
646 | rxvt_keysym_enumerate_helper ( |
|
|
647 | XrmDatabase *database ecb_unused, |
|
|
648 | XrmBindingList bindings ecb_unused, |
|
|
649 | XrmQuarkList quarks, |
|
|
650 | XrmRepresentation *type ecb_unused, |
|
|
651 | XrmValue *value, |
|
|
652 | XPointer closure |
|
|
653 | ) |
|
|
654 | { |
|
|
655 | int last; |
|
|
656 | |
|
|
657 | for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ |
|
|
658 | ; |
|
|
659 | |
|
|
660 | rxvt_term *term = (rxvt_term *)(((void **)closure)[0]); |
|
|
661 | void (*cb)(rxvt_term *, const char *, const char *) |
|
|
662 | = (void (*)(rxvt_term *, const char *, const char *)) |
|
|
663 | (((void **)closure)[1]); |
|
|
664 | |
|
|
665 | cb (term, XrmQuarkToString (quarks[last - 1]), (char *)value->addr); |
|
|
666 | |
|
|
667 | return False; |
|
|
668 | } |
633 | } |
669 | |
634 | |
670 | /* |
635 | /* |
671 | * look for something like this (XK_Delete) |
636 | * look for something like this (XK_Delete) |
672 | * rxvt*keysym.0xFFFF: "\177" |
637 | * rxvt*keysym.0xFFFF: "\177" |
… | |
… | |
774 | |
739 | |
775 | free (ws); |
740 | free (ws); |
776 | return 1; |
741 | return 1; |
777 | } |
742 | } |
778 | |
743 | |
779 | # endif /* KEYSYM_RESOURCE */ |
744 | #endif /* KEYSYM_RESOURCE */ |
780 | |
745 | |
781 | static char * |
746 | static char * |
782 | get_res (XrmDatabase database, const char *program, const char *option) |
747 | get_res (XrmDatabase database, const char *program, const char *option) |
783 | { |
748 | { |
784 | char resource[512]; |
749 | char resource[512]; |
… | |
… | |
855 | } |
820 | } |
856 | } |
821 | } |
857 | #endif /* NO_RESOURCES */ |
822 | #endif /* NO_RESOURCES */ |
858 | } |
823 | } |
859 | |
824 | |
|
|
825 | struct rxvt_enumerate_closure |
|
|
826 | { |
|
|
827 | rxvt_term *term; |
|
|
828 | void (*cb)(rxvt_term *, const char *, const char *); |
|
|
829 | int specific; // iterate over only a specific subhierarchy |
|
|
830 | }; |
|
|
831 | |
|
|
832 | /* |
|
|
833 | * Define key from XrmEnumerateDatabase. |
|
|
834 | * quarks will be something like |
|
|
835 | * "rxvt" "keysym" "0xFF01" |
|
|
836 | * value will be a string |
|
|
837 | */ |
|
|
838 | static int |
|
|
839 | rxvt_enumerate_helper ( |
|
|
840 | XrmDatabase *database ecb_unused, |
|
|
841 | XrmBindingList bindings ecb_unused, |
|
|
842 | XrmQuarkList quarks, |
|
|
843 | XrmRepresentation *type ecb_unused, |
|
|
844 | XrmValue *value, |
|
|
845 | XPointer closure |
|
|
846 | ) |
|
|
847 | { |
|
|
848 | const rxvt_enumerate_closure *data = (const rxvt_enumerate_closure *)closure; |
|
|
849 | |
|
|
850 | if (*quarks == NULLQUARK) return False; |
|
|
851 | |
|
|
852 | // if the quark list starts with a tightly bound quark, we skip it, |
|
|
853 | // as it exactly matched the prefix. Otherwise, it matched because |
|
|
854 | // it started with "*", in which case we assume the prefix is part |
|
|
855 | // of the "*". |
|
|
856 | if (*bindings == XrmBindTightly) |
|
|
857 | { |
|
|
858 | ++quarks, ++bindings; // skip if this is a fixed prefix, rather than a *-match |
|
|
859 | if (*quarks == NULLQUARK) return False; |
|
|
860 | } |
|
|
861 | |
|
|
862 | // specific, a bit misleadingly named, is used when a specific "subclass" |
|
|
863 | // is iterated over, e.g. "keysym", and is used to skip one more |
|
|
864 | // component, as well as all generic prefixes |
|
|
865 | // this is a bit of a hack, ideally, keysym (the only user) should use its |
|
|
866 | // own iteration function, but this ought to be less bloated |
|
|
867 | if (data->specific) |
|
|
868 | { |
|
|
869 | ++quarks, ++bindings; |
|
|
870 | if (*quarks == NULLQUARK) return False; |
|
|
871 | } |
|
|
872 | |
|
|
873 | char *pattern; |
|
|
874 | if (quarks[1] == NULLQUARK) |
|
|
875 | pattern = XrmQuarkToString (quarks[0]); // single component, fast path |
|
|
876 | else |
|
|
877 | { |
|
|
878 | // multiple components, slow path - should be rare, don't optimize for speed |
|
|
879 | int size = 0; |
|
|
880 | |
|
|
881 | for (int i = 0; quarks[i] != NULLQUARK; ++i) |
|
|
882 | size += strlen (XrmQuarkToString (quarks[i])) + 1; |
|
|
883 | |
|
|
884 | pattern = rxvt_temp_buf<char> (size + 1); |
|
|
885 | |
|
|
886 | // now print all components |
|
|
887 | { |
|
|
888 | char *cur = pattern; |
|
|
889 | |
|
|
890 | for (int i = 0; quarks[i] != NULLQUARK; ++i) |
|
|
891 | cur += sprintf (cur, ".%s", XrmQuarkToString (quarks[i])); |
|
|
892 | } |
|
|
893 | |
|
|
894 | ++pattern; // skip initial dot |
|
|
895 | } |
|
|
896 | |
|
|
897 | data->cb (data->term, pattern, (char *)value->addr); |
|
|
898 | |
|
|
899 | return False; |
|
|
900 | } |
|
|
901 | |
860 | void |
902 | void |
861 | rxvt_term::enumerate_keysym_resources (void (*cb)(rxvt_term *, const char *, const char *)) |
903 | rxvt_term::enumerate_resources (void (*cb)(rxvt_term *, const char *, const char *), const char *name_p, const char *class_p) |
862 | { |
904 | { |
863 | /* |
905 | /* |
864 | * [R5 or later]: enumerate the resource database |
906 | * [R5 or later]: enumerate the resource database |
865 | */ |
907 | */ |
|
|
908 | assert (!name_p == !class_p); // both must be specified, or missing |
|
|
909 | |
866 | # ifdef KEYSYM_RESOURCE |
910 | #ifdef KEYSYM_RESOURCE |
867 | void *closure[2] = { |
911 | rxvt_enumerate_closure closure = { this, cb, name_p ? 1 : 0 }; |
868 | (void *)this, |
|
|
869 | (void *)cb, |
|
|
870 | }; |
|
|
871 | |
912 | |
872 | XrmDatabase database = XrmGetDatabase (dpy); |
913 | XrmDatabase database = XrmGetDatabase (dpy); |
873 | XrmName name_prefix[3]; |
914 | XrmName name_prefix[3]; |
874 | XrmClass class_prefix[3]; |
915 | XrmClass class_prefix[3]; |
875 | |
916 | |
876 | name_prefix[1] = XrmStringToName ("keysym"); |
917 | name_prefix[1] = name_p ? XrmStringToName (name_p) : NULLQUARK; |
877 | name_prefix[2] = NULLQUARK; |
918 | name_prefix[2] = NULLQUARK; |
878 | class_prefix[1] = XrmStringToName ("Keysym"); |
919 | class_prefix[1] = class_p ? XrmStringToName (class_p) : NULLQUARK; |
879 | class_prefix[2] = NULLQUARK; |
920 | class_prefix[2] = NULLQUARK; |
880 | |
921 | |
881 | # ifdef RESFALLBACK |
922 | # ifdef RESFALLBACK |
882 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); |
923 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); |
883 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
|
|
884 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
924 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
885 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
925 | XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure); |
886 | # endif |
926 | # endif |
887 | |
927 | |
888 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); |
928 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); |
889 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
929 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
890 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
930 | XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure); |
891 | |
931 | |
892 | name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]); |
932 | name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]); |
893 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
933 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
894 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
934 | XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure); |
895 | # endif |
935 | #endif |
896 | } |
936 | } |
897 | |
937 | |
898 | void |
938 | void |
899 | rxvt_term::extract_keysym_resources () |
939 | rxvt_term::extract_keysym_resources () |
900 | { |
940 | { |
|
|
941 | #ifdef KEYSYM_RESOURCE |
901 | enumerate_keysym_resources (rxvt_define_key); |
942 | enumerate_keysym_resources (rxvt_define_key); |
|
|
943 | #endif |
902 | } |
944 | } |
903 | |
945 | |
904 | /*----------------------- end-of-file (C source) -----------------------*/ |
946 | /*----------------------- end-of-file (C source) -----------------------*/ |
905 | |
947 | |