… | |
… | |
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"), |
… | |
… | |
194 | RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"), |
187 | RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"), |
195 | #endif /* NO_CURSORCOLOR */ |
188 | #endif /* NO_CURSORCOLOR */ |
196 | STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), |
189 | STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), |
197 | STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), |
190 | STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), |
198 | STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"), |
191 | 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 |
192 | #if ENABLE_EWMH |
204 | STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), |
193 | STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), |
|
|
194 | #endif |
|
|
195 | #ifdef HAVE_XMU |
|
|
196 | RSTRG (Rs_pointerShape, "pointerShape", "string"), |
205 | #endif |
197 | #endif |
206 | /* fonts: command-line option = resource name */ |
198 | /* fonts: command-line option = resource name */ |
207 | STRG (Rs_font, "font", "fn", "fontname", "normal text font"), |
199 | STRG (Rs_font, "font", "fn", "fontname", "normal text font"), |
208 | #if ENABLE_STYLES |
200 | #if ENABLE_STYLES |
209 | STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"), |
201 | STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"), |
… | |
… | |
627 | |
619 | |
628 | /*}}} */ |
620 | /*}}} */ |
629 | |
621 | |
630 | /*----------------------------------------------------------------------*/ |
622 | /*----------------------------------------------------------------------*/ |
631 | |
623 | |
632 | # ifdef KEYSYM_RESOURCE |
624 | #ifdef KEYSYM_RESOURCE |
633 | static void |
625 | static void |
634 | rxvt_define_key (rxvt_term *term, const char *k, const char *v) |
626 | rxvt_define_key (rxvt_term *term, const char *k, const char *v) |
635 | { |
627 | { |
636 | term->bind_action (k, v); |
628 | 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 | } |
629 | } |
669 | |
630 | |
670 | /* |
631 | /* |
671 | * look for something like this (XK_Delete) |
632 | * look for something like this (XK_Delete) |
672 | * rxvt*keysym.0xFFFF: "\177" |
633 | * rxvt*keysym.0xFFFF: "\177" |
… | |
… | |
774 | |
735 | |
775 | free (ws); |
736 | free (ws); |
776 | return 1; |
737 | return 1; |
777 | } |
738 | } |
778 | |
739 | |
779 | # endif /* KEYSYM_RESOURCE */ |
740 | #endif /* KEYSYM_RESOURCE */ |
780 | |
741 | |
781 | static char * |
742 | static char * |
782 | get_res (XrmDatabase database, const char *program, const char *option) |
743 | get_res (XrmDatabase database, const char *program, const char *option) |
783 | { |
744 | { |
784 | char resource[512]; |
745 | char resource[512]; |
… | |
… | |
855 | } |
816 | } |
856 | } |
817 | } |
857 | #endif /* NO_RESOURCES */ |
818 | #endif /* NO_RESOURCES */ |
858 | } |
819 | } |
859 | |
820 | |
|
|
821 | struct rxvt_enumerate_closure |
|
|
822 | { |
|
|
823 | rxvt_term *term; |
|
|
824 | void (*cb)(rxvt_term *, const char *, const char *); |
|
|
825 | int specific; // iterate over only a specific subhierarchy |
|
|
826 | }; |
|
|
827 | |
|
|
828 | /* |
|
|
829 | * Define key from XrmEnumerateDatabase. |
|
|
830 | * quarks will be something like |
|
|
831 | * "rxvt" "keysym" "0xFF01" |
|
|
832 | * value will be a string |
|
|
833 | */ |
|
|
834 | static int |
|
|
835 | rxvt_enumerate_helper ( |
|
|
836 | XrmDatabase *database ecb_unused, |
|
|
837 | XrmBindingList bindings ecb_unused, |
|
|
838 | XrmQuarkList quarks, |
|
|
839 | XrmRepresentation *type ecb_unused, |
|
|
840 | XrmValue *value, |
|
|
841 | XPointer closure |
|
|
842 | ) |
|
|
843 | { |
|
|
844 | const rxvt_enumerate_closure *data = (const rxvt_enumerate_closure *)closure; |
|
|
845 | |
|
|
846 | if (*quarks == NULLQUARK) return False; |
|
|
847 | |
|
|
848 | // if the quark list starts with a tightly bound quark, we skip it, |
|
|
849 | // as it exactly matched the prefix. Otherwise, it matched because |
|
|
850 | // it started with "*", in which case we assume the prefix is part |
|
|
851 | // of the "*". |
|
|
852 | if (*bindings == XrmBindTightly) |
|
|
853 | { |
|
|
854 | ++quarks, ++bindings; // skip if this is a fixed prefix, rather than a *-match |
|
|
855 | if (*quarks == NULLQUARK) return False; |
|
|
856 | } |
|
|
857 | |
|
|
858 | // specific, a bit misleadingly named, is used when a specific "subclass" |
|
|
859 | // is iterated over, e.g. "keysym", and is used to skip one more |
|
|
860 | // component, as well as all generic prefixes |
|
|
861 | // this is a bit of a hack, ideally, keysym (the only user) should use its |
|
|
862 | // own iteration function, but this ought to be less bloated |
|
|
863 | if (data->specific) |
|
|
864 | { |
|
|
865 | ++quarks, ++bindings; |
|
|
866 | if (*quarks == NULLQUARK) return False; |
|
|
867 | } |
|
|
868 | |
|
|
869 | char *pattern; |
|
|
870 | if (quarks[1] == NULLQUARK) |
|
|
871 | pattern = XrmQuarkToString (quarks[0]); // single component, fast path |
|
|
872 | else |
|
|
873 | { |
|
|
874 | // multiple components, slow path - should be rare, don't optimize for speed |
|
|
875 | int size = 0; |
|
|
876 | |
|
|
877 | for (int i = 0; quarks[i] != NULLQUARK; ++i) |
|
|
878 | size += strlen (XrmQuarkToString (quarks[i])) + 1; |
|
|
879 | |
|
|
880 | pattern = rxvt_temp_buf<char> (size + 1); |
|
|
881 | |
|
|
882 | // now print all components |
|
|
883 | { |
|
|
884 | char *cur = pattern; |
|
|
885 | |
|
|
886 | for (int i = 0; quarks[i] != NULLQUARK; ++i) |
|
|
887 | cur += sprintf (cur, ".%s", XrmQuarkToString (quarks[i])); |
|
|
888 | } |
|
|
889 | |
|
|
890 | ++pattern; // skip initial dot |
|
|
891 | } |
|
|
892 | |
|
|
893 | data->cb (data->term, pattern, (char *)value->addr); |
|
|
894 | |
|
|
895 | return False; |
|
|
896 | } |
|
|
897 | |
860 | void |
898 | void |
861 | rxvt_term::enumerate_keysym_resources (void (*cb)(rxvt_term *, const char *, const char *)) |
899 | rxvt_term::enumerate_resources (void (*cb)(rxvt_term *, const char *, const char *), const char *name_p, const char *class_p) |
862 | { |
900 | { |
863 | /* |
901 | /* |
864 | * [R5 or later]: enumerate the resource database |
902 | * [R5 or later]: enumerate the resource database |
865 | */ |
903 | */ |
|
|
904 | assert (!name_p == !class_p); // both must be specified, or missing |
|
|
905 | |
866 | # ifdef KEYSYM_RESOURCE |
906 | #ifdef KEYSYM_RESOURCE |
867 | void *closure[2] = { |
907 | rxvt_enumerate_closure closure = { this, cb, name_p ? 1 : 0 }; |
868 | (void *)this, |
|
|
869 | (void *)cb, |
|
|
870 | }; |
|
|
871 | |
908 | |
872 | XrmDatabase database = XrmGetDatabase (dpy); |
909 | XrmDatabase database = XrmGetDatabase (dpy); |
873 | XrmName name_prefix[3]; |
910 | XrmName name_prefix[3]; |
874 | XrmClass class_prefix[3]; |
911 | XrmClass class_prefix[3]; |
875 | |
912 | |
876 | name_prefix[1] = XrmStringToName ("keysym"); |
913 | name_prefix[1] = name_p ? XrmStringToName (name_p) : NULLQUARK; |
877 | name_prefix[2] = NULLQUARK; |
914 | name_prefix[2] = NULLQUARK; |
878 | class_prefix[1] = XrmStringToName ("Keysym"); |
915 | class_prefix[1] = class_p ? XrmStringToName (class_p) : NULLQUARK; |
879 | class_prefix[2] = NULLQUARK; |
916 | class_prefix[2] = NULLQUARK; |
880 | |
917 | |
881 | # ifdef RESFALLBACK |
918 | # ifdef RESFALLBACK |
882 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); |
919 | 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, |
920 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
885 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
921 | XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure); |
886 | # endif |
922 | # endif |
887 | |
923 | |
888 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); |
924 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); |
889 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
925 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
890 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
926 | XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure); |
891 | |
927 | |
892 | name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]); |
928 | name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]); |
893 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
929 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
894 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
930 | XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure); |
895 | # endif |
931 | #endif |
896 | } |
932 | } |
897 | |
933 | |
898 | void |
934 | void |
899 | rxvt_term::extract_keysym_resources () |
935 | rxvt_term::extract_keysym_resources () |
900 | { |
936 | { |