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.180 by sf-exg, Sat Aug 16 10:51:23 2014 UTC vs.
Revision 1.190 by sf-exg, Tue Oct 13 08:10:43 2015 UTC

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.
99 SWCH ("ic", Opt_iconic, 0, NULL), /* short form */ 99 SWCH ("ic", Opt_iconic, 0, NULL), /* short form */
100 STRG (Rs_chdir, "chdir", "cd", "string", "start shell in this directory"), 100 STRG (Rs_chdir, "chdir", "cd", "string", "start shell in this directory"),
101 SWCH ("dockapp", Opt_dockapp, 0, "start as dockapp"), 101 SWCH ("dockapp", Opt_dockapp, 0, "start as dockapp"),
102 BOOL (Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo, 0, "reverse video"), 102 BOOL (Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo, 0, "reverse video"),
103 BOOL (Rs_loginShell, "loginShell", "ls", Opt_loginShell, 0, "login shell"), 103 BOOL (Rs_loginShell, "loginShell", "ls", Opt_loginShell, 0, "login shell"),
104 STRG (Rs_multiClickTime, "multiClickTime", "mc", "number", "Maximum time (in ms) between multi-click selections"), 104 STRG (Rs_multiClickTime, "multiClickTime", "mc", "number", "maximum time (in ms) between multi-click selections"),
105 BOOL (Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, 0, "jump scrolling"), 105 BOOL (Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, 0, "jump scrolling"),
106 BOOL (Rs_skipScroll, "skipScroll", "ss", Opt_skipScroll, 0, "skip scrolling"), 106 BOOL (Rs_skipScroll, "skipScroll", "ss", Opt_skipScroll, 0, "skip scrolling"),
107 BOOL (Rs_pastableTabs, "pastableTabs", "ptab", Opt_pastableTabs, 0, "tab characters are pastable"), 107 BOOL (Rs_pastableTabs, "pastableTabs", "ptab", Opt_pastableTabs, 0, "tab characters are pastable"),
108 RSTRG (Rs_scrollstyle, "scrollstyle", "mode"), 108 RSTRG (Rs_scrollstyle, "scrollstyle", "mode"),
109 BOOL (Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, 0, "scrollbar"), 109 BOOL (Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, 0, "scrollbar"),
201 STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"), 201 STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"),
202#endif 202#endif
203#if ENABLE_EWMH 203#if ENABLE_EWMH
204 STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), 204 STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"),
205#endif 205#endif
206#ifdef HAVE_XMU
207 RSTRG (Rs_pointerShape, "pointerShape", "string"),
208#endif
206 /* fonts: command-line option = resource name */ 209 /* fonts: command-line option = resource name */
207 STRG (Rs_font, "font", "fn", "fontname", "normal text font"), 210 STRG (Rs_font, "font", "fn", "fontname", "normal text font"),
208#if ENABLE_STYLES 211#if ENABLE_STYLES
209 STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"), 212 STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"),
210 STRG (Rs_italicFont, "italicFont", "fi", "fontname", "italic font"), 213 STRG (Rs_italicFont, "italicFont", "fi", "fontname", "italic font"),
625 return 0; 628 return 0;
626} 629}
627 630
628/*}}} */ 631/*}}} */
629 632
630#ifndef NO_RESOURCES
631/*----------------------------------------------------------------------*/ 633/*----------------------------------------------------------------------*/
632 634
633# ifdef KEYSYM_RESOURCE 635#ifdef KEYSYM_RESOURCE
634static void 636static void
635rxvt_define_key (rxvt_term *term, const char *k, const char *v) 637rxvt_define_key (rxvt_term *term, const char *k, const char *v)
636{ 638{
637 term->bind_action (k, v); 639 term->bind_action (k, v);
638} 640}
707 { "4", 1, Mod4Mask }, 709 { "4", 1, Mod4Mask },
708 { "5", 1, Mod5Mask }, 710 { "5", 1, Mod5Mask },
709}; 711};
710 712
711int 713int
712rxvt_term::bind_action (const char *str, const char *arg) 714rxvt_term::parse_keysym (const char *str, unsigned int &state)
713{ 715{
714 int sym; 716 int sym;
715 unsigned int state = 0;
716 const char *key = strrchr (str, '-'); 717 const char *key = strrchr (str, '-');
718
719 state = 0;
717 720
718 if (!key) 721 if (!key)
719 key = str; 722 key = str;
720 else 723 else
721 key++; 724 key++;
722 725
723 // string or key is empty 726 // string or key is empty
724 if (*arg == '\0' || *key == '\0') 727 if (*key == '\0')
725 return -1; 728 return -1;
726 729
727 // parse modifiers 730 // parse modifiers
728 while (str < key) 731 while (str < key)
729 { 732 {
754 sym = strtol (str, &end, 16); 757 sym = strtol (str, &end, 16);
755 if (*end) 758 if (*end)
756 return -1; 759 return -1;
757 } 760 }
758 761
762 return sym;
763}
764
765int
766rxvt_term::bind_action (const char *str, const char *arg)
767{
768 int sym;
769 unsigned int state;
770
771 if (*arg == '\0' || (sym = parse_keysym (str, state)) == -1)
772 return -1;
773
759 wchar_t *ws = rxvt_mbstowcs (arg); 774 wchar_t *ws = rxvt_mbstowcs (arg);
760 if (!HOOK_INVOKE ((this, HOOK_REGISTER_COMMAND, DT_INT, sym, DT_INT, state, DT_WCS_LEN, ws, wcslen (ws), DT_END))) 775 if (!HOOK_INVOKE ((this, HOOK_REGISTER_COMMAND, DT_INT, sym, DT_INT, state, DT_WCS_LEN, ws, wcslen (ws), DT_END)))
761 keyboard->register_action (sym, state, ws); 776 keyboard->register_action (sym, state, ws);
762 777
763 free (ws); 778 free (ws);
764 return 1; 779 return 1;
765} 780}
766 781
767# endif /* KEYSYM_RESOURCE */ 782#endif /* KEYSYM_RESOURCE */
768#endif /* NO_RESOURCES */
769 783
770static char * 784static char *
771get_res (XrmDatabase database, const char *program, const char *option) 785get_res (XrmDatabase database, const char *program, const char *option)
772{ 786{
773 char resource[512]; 787 char resource[512];
847} 861}
848 862
849void 863void
850rxvt_term::enumerate_keysym_resources (void (*cb)(rxvt_term *, const char *, const char *)) 864rxvt_term::enumerate_keysym_resources (void (*cb)(rxvt_term *, const char *, const char *))
851{ 865{
852#ifndef NO_RESOURCES
853 /* 866 /*
854 * [R5 or later]: enumerate the resource database 867 * [R5 or later]: enumerate the resource database
855 */ 868 */
856# ifdef KEYSYM_RESOURCE 869#ifdef KEYSYM_RESOURCE
857 void *closure[2] = { 870 void *closure[2] = {
858 (void *)this, 871 (void *)this,
859 (void *)cb, 872 (void *)cb,
860 }; 873 };
861 874
862 XrmDatabase database = XrmGetDatabase (dpy); 875 XrmDatabase database = XrmGetDatabase (dpy);
863 XrmName name_prefix[3]; 876 XrmName name_prefix[3];
864 XrmClass class_prefix[3]; 877 XrmClass class_prefix[3];
865 878
866 name_prefix[0] = XrmStringToName (rs[Rs_name]);
867 name_prefix[1] = XrmStringToName ("keysym"); 879 name_prefix[1] = XrmStringToName ("keysym");
868 name_prefix[2] = NULLQUARK; 880 name_prefix[2] = NULLQUARK;
869 class_prefix[0] = XrmStringToName (RESCLASS);
870 class_prefix[1] = XrmStringToName ("Keysym"); 881 class_prefix[1] = XrmStringToName ("Keysym");
871 class_prefix[2] = NULLQUARK; 882 class_prefix[2] = NULLQUARK;
872 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ 883
873 XrmEnumerateDatabase (database, name_prefix, class_prefix,
874 XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure);
875# ifdef RESFALLBACK 884# ifdef RESFALLBACK
876 name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); 885 name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK);
877 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ 886 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
878 XrmEnumerateDatabase (database, name_prefix, class_prefix, 887 XrmEnumerateDatabase (database, name_prefix, class_prefix,
879 XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); 888 XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure);
880# endif
881# endif 889# endif
882 890
883#endif /* NO_RESOURCES */ 891 name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS);
892 XrmEnumerateDatabase (database, name_prefix, class_prefix,
893 XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure);
894
895 name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]);
896 XrmEnumerateDatabase (database, name_prefix, class_prefix,
897 XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure);
898#endif
884} 899}
885 900
886void 901void
887rxvt_term::extract_keysym_resources () 902rxvt_term::extract_keysym_resources ()
888{ 903{
904#ifdef KEYSYM_RESOURCE
889 enumerate_keysym_resources (rxvt_define_key); 905 enumerate_keysym_resources (rxvt_define_key);
906#endif
890} 907}
891 908
892/*----------------------- end-of-file (C source) -----------------------*/ 909/*----------------------- end-of-file (C source) -----------------------*/
893 910

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines