ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/xdefaults.C
(Generate patch)

Comparing rxvt-unicode/src/xdefaults.C (file contents):
Revision 1.192 by sf-exg, Thu Jul 14 05:33:26 2016 UTC vs.
Revision 1.197 by root, Sat Jul 3 04:04:13 2021 UTC

134#endif 134#endif
135#ifdef MOUSE_WHEEL 135#ifdef MOUSE_WHEEL
136 BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, 0, NULL), 136 BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, 0, NULL),
137#endif 137#endif
138#if ENABLE_FRILLS 138#if ENABLE_FRILLS
139 BOOL (Rs_disablePasteBrackets, "disablePasteBrackets", "dpb", Opt_disablePasteBrackets, 0, "do not emit bracketed paste mode sequences"),
139 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"),
140 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"),
141 BOOL (Rs_cursorUnderline, "cursorUnderline", "uc", Opt_cursorUnderline, 0, "underline cursor"), 142 BOOL (Rs_cursorUnderline, "cursorUnderline", "uc", Opt_cursorUnderline, 0, "underline cursor"),
142#endif 143#endif
143#if CURSOR_BLINK 144#if CURSOR_BLINK
255 RSTRG (Rs_answerbackstring, "answerbackString", "string"), 256 RSTRG (Rs_answerbackstring, "answerbackString", "string"),
256#ifndef NO_SECONDARY_SCREEN 257#ifndef NO_SECONDARY_SCREEN
257 BOOL (Rs_secondaryScreen, "secondaryScreen", "ssc", Opt_secondaryScreen, 0, "enable secondary screen"), 258 BOOL (Rs_secondaryScreen, "secondaryScreen", "ssc", Opt_secondaryScreen, 0, "enable secondary screen"),
258 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"),
259#endif 260#endif
261#if ENABLE_FRILLS
262 STRG (Rs_rewrapMode, "rewrapMode", "rm", "string", "rewrap mode (auto, always, never)"),
263#endif
260#if ENABLE_PERL 264#if ENABLE_PERL
261 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
262 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
263 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
264 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"),
624#ifdef KEYSYM_RESOURCE 628#ifdef KEYSYM_RESOURCE
625static void 629static void
626rxvt_define_key (rxvt_term *term, const char *k, const char *v) 630rxvt_define_key (rxvt_term *term, const char *k, const char *v)
627{ 631{
628 term->bind_action (k, v); 632 term->bind_action (k, v);
629}
630
631/*
632 * Define key from XrmEnumerateDatabase.
633 * quarks will be something like
634 * "rxvt" "keysym" "0xFF01"
635 * value will be a string
636 */
637static int
638rxvt_enumerate_helper (
639 XrmDatabase *database ecb_unused,
640 XrmBindingList bindings ecb_unused,
641 XrmQuarkList quarks,
642 XrmRepresentation *type ecb_unused,
643 XrmValue *value,
644 XPointer closure
645)
646{
647 int last;
648
649 for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */
650 ;
651
652 rxvt_term *term = (rxvt_term *)(((void **)closure)[0]);
653 void (*cb)(rxvt_term *, const char *, const char *)
654 = (void (*)(rxvt_term *, const char *, const char *))
655 (((void **)closure)[1]);
656
657 cb (term, XrmQuarkToString (quarks[last - 1]), (char *)value->addr);
658
659 return False;
660} 633}
661 634
662/* 635/*
663 * look for something like this (XK_Delete) 636 * look for something like this (XK_Delete)
664 * rxvt*keysym.0xFFFF: "\177" 637 * rxvt*keysym.0xFFFF: "\177"
847 } 820 }
848 } 821 }
849#endif /* NO_RESOURCES */ 822#endif /* NO_RESOURCES */
850} 823}
851 824
825struct 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 */
838static int
839rxvt_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
852void 902void
853rxvt_term::enumerate_resources (void (*cb)(rxvt_term *, const char *, const char *), const char *name_p, const char *class_p) 903rxvt_term::enumerate_resources (void (*cb)(rxvt_term *, const char *, const char *), const char *name_p, const char *class_p)
854{ 904{
855 /* 905 /*
856 * [R5 or later]: enumerate the resource database 906 * [R5 or later]: enumerate the resource database
857 */ 907 */
908 assert (!name_p == !class_p); // both must be specified, or missing
909
858#ifdef KEYSYM_RESOURCE 910#ifdef KEYSYM_RESOURCE
859 void *closure[2] = { 911 rxvt_enumerate_closure closure = { this, cb, name_p ? 1 : 0 };
860 (void *)this,
861 (void *)cb,
862 };
863 912
864 XrmDatabase database = XrmGetDatabase (dpy); 913 XrmDatabase database = XrmGetDatabase (dpy);
865 XrmName name_prefix[3]; 914 XrmName name_prefix[3];
866 XrmClass class_prefix[3]; 915 XrmClass class_prefix[3];
867 916
870 class_prefix[1] = class_p ? XrmStringToName (class_p) : NULLQUARK; 919 class_prefix[1] = class_p ? XrmStringToName (class_p) : NULLQUARK;
871 class_prefix[2] = NULLQUARK; 920 class_prefix[2] = NULLQUARK;
872 921
873# ifdef RESFALLBACK 922# ifdef RESFALLBACK
874 name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); 923 name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK);
875 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
876 XrmEnumerateDatabase (database, name_prefix, class_prefix, 924 XrmEnumerateDatabase (database, name_prefix, class_prefix,
877 XrmEnumOneLevel, rxvt_enumerate_helper, (XPointer)closure); 925 XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure);
878# endif 926# endif
879 927
880 name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); 928 name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS);
881 XrmEnumerateDatabase (database, name_prefix, class_prefix, 929 XrmEnumerateDatabase (database, name_prefix, class_prefix,
882 XrmEnumOneLevel, rxvt_enumerate_helper, (XPointer)closure); 930 XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure);
883 931
884 name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]); 932 name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]);
885 XrmEnumerateDatabase (database, name_prefix, class_prefix, 933 XrmEnumerateDatabase (database, name_prefix, class_prefix,
886 XrmEnumOneLevel, rxvt_enumerate_helper, (XPointer)closure); 934 XrmEnumAllLevels, rxvt_enumerate_helper, (XPointer)&closure);
887#endif 935#endif
888} 936}
889 937
890void 938void
891rxvt_term::extract_keysym_resources () 939rxvt_term::extract_keysym_resources ()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines