… | |
… | |
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 | } |
629 | } |
|
|
630 | |
|
|
631 | struct rxvt_enumerate_closure |
|
|
632 | { |
|
|
633 | rxvt_term *term; |
|
|
634 | void (*cb)(rxvt_term *, const char *, const char *); |
|
|
635 | int specific; // iterate over only a specific subhierarchy |
|
|
636 | }; |
638 | |
637 | |
639 | /* |
638 | /* |
640 | * Define key from XrmEnumerateDatabase. |
639 | * Define key from XrmEnumerateDatabase. |
641 | * quarks will be something like |
640 | * quarks will be something like |
642 | * "rxvt" "keysym" "0xFF01" |
641 | * "rxvt" "keysym" "0xFF01" |
643 | * value will be a string |
642 | * value will be a string |
644 | */ |
643 | */ |
645 | static int |
644 | static int |
646 | rxvt_keysym_enumerate_helper ( |
645 | rxvt_enumerate_helper ( |
647 | XrmDatabase *database ecb_unused, |
646 | XrmDatabase *database ecb_unused, |
648 | XrmBindingList bindings ecb_unused, |
647 | XrmBindingList bindings ecb_unused, |
649 | XrmQuarkList quarks, |
648 | XrmQuarkList quarks, |
650 | XrmRepresentation *type ecb_unused, |
649 | XrmRepresentation *type ecb_unused, |
651 | XrmValue *value, |
650 | XrmValue *value, |
652 | XPointer closure |
651 | XPointer closure |
653 | ) |
652 | ) |
654 | { |
653 | { |
655 | int last; |
654 | const rxvt_enumerate_closure *data = (const rxvt_enumerate_closure *)closure; |
656 | |
655 | |
657 | for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ |
656 | if (*quarks == NULLQUARK) return False; |
|
|
657 | |
|
|
658 | // if the quark list starts with a tighly bound quark, we skip it, |
|
|
659 | // as it is the exactly matched the prefix. Otherwise, it matched because |
|
|
660 | // it started with "*", in which case we assuime the prefix is part |
|
|
661 | // of the "*". |
|
|
662 | if (*bindings == XrmBindTightly) |
658 | ; |
663 | { |
|
|
664 | ++quarks, ++bindings; // skip if this is a fixed prefix, rather than a *-match |
|
|
665 | if (*quarks == NULLQUARK) return False; |
|
|
666 | } |
659 | |
667 | |
660 | rxvt_term *term = (rxvt_term *)(((void **)closure)[0]); |
668 | // specific, a bit misleadingly named, is used when a specific "subclass" |
661 | void (*cb)(rxvt_term *, const char *, const char *) |
669 | // is iterated over, e.g. "keysym", and is used to skip one more |
662 | = (void (*)(rxvt_term *, const char *, const char *)) |
670 | // component, as well as all generic prefixes |
663 | (((void **)closure)[1]); |
671 | // this is a bit of a hack, ideally, keysym (the only user) should use its |
|
|
672 | // own iteration function, but this ought to be less bloated |
|
|
673 | if (data->specific) |
|
|
674 | { |
|
|
675 | if (*bindings != XrmBindTightly) |
|
|
676 | return False; |
664 | |
677 | |
665 | cb (term, XrmQuarkToString (quarks[last - 1]), (char *)value->addr); |
678 | ++quarks, ++bindings; // skip if this is a fixed prefix, rather than a *-match |
|
|
679 | if (*quarks == NULLQUARK) return False; |
|
|
680 | } |
|
|
681 | |
|
|
682 | char *pattern; |
|
|
683 | if (quarks[1] == NULLQUARK) |
|
|
684 | pattern = XrmQuarkToString (quarks[0]); // single component, fats path |
|
|
685 | else |
|
|
686 | { |
|
|
687 | // multiple components, slow path - should be rare, to don't optimize for speed |
|
|
688 | int size = 0; |
|
|
689 | |
|
|
690 | for (int i = 0; quarks[i] != NULLQUARK; ++i) |
|
|
691 | size += strlen (XrmQuarkToString (quarks[i])) + 1; |
|
|
692 | |
|
|
693 | pattern = rxvt_temp_buf<char> (size + 1); |
|
|
694 | |
|
|
695 | // now print all components |
|
|
696 | { |
|
|
697 | char *cur = pattern; |
|
|
698 | |
|
|
699 | for (int i = 0; quarks[i] != NULLQUARK; ++i) |
|
|
700 | cur += sprintf (cur, ".%s", XrmQuarkToString (quarks[i])); |
|
|
701 | } |
|
|
702 | |
|
|
703 | ++pattern; // skip initial dot |
|
|
704 | } |
|
|
705 | |
|
|
706 | data->cb (data->term, pattern, (char *)value->addr); |
666 | |
707 | |
667 | return False; |
708 | return False; |
668 | } |
709 | } |
669 | |
710 | |
670 | /* |
711 | /* |
… | |
… | |
774 | |
815 | |
775 | free (ws); |
816 | free (ws); |
776 | return 1; |
817 | return 1; |
777 | } |
818 | } |
778 | |
819 | |
779 | # endif /* KEYSYM_RESOURCE */ |
820 | #endif /* KEYSYM_RESOURCE */ |
780 | |
821 | |
781 | static char * |
822 | static char * |
782 | get_res (XrmDatabase database, const char *program, const char *option) |
823 | get_res (XrmDatabase database, const char *program, const char *option) |
783 | { |
824 | { |
784 | char resource[512]; |
825 | char resource[512]; |
… | |
… | |
856 | } |
897 | } |
857 | #endif /* NO_RESOURCES */ |
898 | #endif /* NO_RESOURCES */ |
858 | } |
899 | } |
859 | |
900 | |
860 | void |
901 | void |
861 | rxvt_term::enumerate_keysym_resources (void (*cb)(rxvt_term *, const char *, const char *)) |
902 | rxvt_term::enumerate_resources (void (*cb)(rxvt_term *, const char *, const char *), const char *name_p, const char *class_p) |
862 | { |
903 | { |
863 | /* |
904 | /* |
864 | * [R5 or later]: enumerate the resource database |
905 | * [R5 or later]: enumerate the resource database |
865 | */ |
906 | */ |
|
|
907 | assert (!name_p == !class_p); // both must be specified, or missing |
|
|
908 | |
866 | # ifdef KEYSYM_RESOURCE |
909 | #ifdef KEYSYM_RESOURCE |
867 | void *closure[2] = { |
910 | rxvt_enumerate_closure closure = { this, cb, name_p ? 1 : 0 }; |
868 | (void *)this, |
|
|
869 | (void *)cb, |
|
|
870 | }; |
|
|
871 | |
911 | |
872 | XrmDatabase database = XrmGetDatabase (dpy); |
912 | XrmDatabase database = XrmGetDatabase (dpy); |
873 | XrmName name_prefix[3]; |
913 | XrmName name_prefix[3]; |
874 | XrmClass class_prefix[3]; |
914 | XrmClass class_prefix[3]; |
875 | |
915 | |
876 | name_prefix[1] = XrmStringToName ("keysym"); |
916 | name_prefix[1] = name_p ? XrmStringToName (name_p) : NULLQUARK; |
877 | name_prefix[2] = NULLQUARK; |
917 | name_prefix[2] = NULLQUARK; |
878 | class_prefix[1] = XrmStringToName ("Keysym"); |
918 | class_prefix[1] = class_p ? XrmStringToName (class_p) : NULLQUARK; |
879 | class_prefix[2] = NULLQUARK; |
919 | class_prefix[2] = NULLQUARK; |
880 | |
920 | |
881 | # ifdef RESFALLBACK |
921 | # ifdef RESFALLBACK |
882 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); |
922 | 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, |
923 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
885 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
924 | XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure); |
886 | # endif |
925 | # endif |
887 | |
926 | |
888 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); |
927 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); |
889 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
928 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
890 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
929 | XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure); |
891 | |
930 | |
892 | name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]); |
931 | name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]); |
893 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
932 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
894 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
933 | XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure); |
895 | # endif |
934 | #endif |
896 | } |
935 | } |
897 | |
936 | |
898 | void |
937 | void |
899 | rxvt_term::extract_keysym_resources () |
938 | rxvt_term::extract_keysym_resources () |
900 | { |
939 | { |