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.193 by root, Tue Sep 17 20:38:14 2019 UTC vs.
Revision 1.194 by root, Tue Sep 17 20:38:53 2019 UTC

626rxvt_define_key (rxvt_term *term, const char *k, const char *v) 626rxvt_define_key (rxvt_term *term, const char *k, const char *v)
627{ 627{
628 term->bind_action (k, v); 628 term->bind_action (k, v);
629} 629}
630 630
631struct 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};
637
638/*
639 * Define key from XrmEnumerateDatabase.
640 * quarks will be something like
641 * "rxvt" "keysym" "0xFF01"
642 * value will be a string
643 */
644static int
645rxvt_enumerate_helper (
646 XrmDatabase *database ecb_unused,
647 XrmBindingList bindings ecb_unused,
648 XrmQuarkList quarks,
649 XrmRepresentation *type ecb_unused,
650 XrmValue *value,
651 XPointer closure
652)
653{
654 const rxvt_enumerate_closure *data = (const rxvt_enumerate_closure *)closure;
655
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)
663 {
664 ++quarks, ++bindings; // skip if this is a fixed prefix, rather than a *-match
665 if (*quarks == NULLQUARK) return False;
666 }
667
668 // specific, a bit misleadingly named, is used when a specific "subclass"
669 // is iterated over, e.g. "keysym", and is used to skip one more
670 // component, as well as all generic prefixes
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;
677
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);
707
708 return False;
709}
710
711/* 631/*
712 * look for something like this (XK_Delete) 632 * look for something like this (XK_Delete)
713 * rxvt*keysym.0xFFFF: "\177" 633 * rxvt*keysym.0xFFFF: "\177"
714 */ 634 */
715 635
896 } 816 }
897 } 817 }
898#endif /* NO_RESOURCES */ 818#endif /* NO_RESOURCES */
899} 819}
900 820
821struct 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 */
834static int
835rxvt_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 tighly bound quark, we skip it,
849 // as it is the exactly matched the prefix. Otherwise, it matched because
850 // it started with "*", in which case we assuime 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 if (*bindings != XrmBindTightly)
866 return False;
867
868 ++quarks, ++bindings; // skip if this is a fixed prefix, rather than a *-match
869 if (*quarks == NULLQUARK) return False;
870 }
871
872 char *pattern;
873 if (quarks[1] == NULLQUARK)
874 pattern = XrmQuarkToString (quarks[0]); // single component, fats path
875 else
876 {
877 // multiple components, slow path - should be rare, to don't optimize for speed
878 int size = 0;
879
880 for (int i = 0; quarks[i] != NULLQUARK; ++i)
881 size += strlen (XrmQuarkToString (quarks[i])) + 1;
882
883 pattern = rxvt_temp_buf<char> (size + 1);
884
885 // now print all components
886 {
887 char *cur = pattern;
888
889 for (int i = 0; quarks[i] != NULLQUARK; ++i)
890 cur += sprintf (cur, ".%s", XrmQuarkToString (quarks[i]));
891 }
892
893 ++pattern; // skip initial dot
894 }
895
896 data->cb (data->term, pattern, (char *)value->addr);
897
898 return False;
899}
900
901void 901void
902rxvt_term::enumerate_resources (void (*cb)(rxvt_term *, const char *, const char *), const char *name_p, const char *class_p) 902rxvt_term::enumerate_resources (void (*cb)(rxvt_term *, const char *, const char *), const char *name_p, const char *class_p)
903{ 903{
904 /* 904 /*
905 * [R5 or later]: enumerate the resource database 905 * [R5 or later]: enumerate the resource database

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines