… | |
… | |
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 | BOOL (Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, 0, "jump scrolling"), |
105 | BOOL (Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, 0, "jump scrolling"), |
105 | BOOL (Rs_skipScroll, "skipScroll", "ss", Opt_skipScroll, 0, "skip scrolling"), |
106 | BOOL (Rs_skipScroll, "skipScroll", "ss", Opt_skipScroll, 0, "skip scrolling"), |
106 | 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"), |
107 | RSTRG (Rs_scrollstyle, "scrollstyle", "mode"), |
108 | RSTRG (Rs_scrollstyle, "scrollstyle", "mode"), |
108 | BOOL (Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, 0, "scrollbar"), |
109 | BOOL (Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, 0, "scrollbar"), |
… | |
… | |
200 | STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"), |
201 | STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"), |
201 | #endif |
202 | #endif |
202 | #if ENABLE_EWMH |
203 | #if ENABLE_EWMH |
203 | STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), |
204 | STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), |
204 | #endif |
205 | #endif |
|
|
206 | #ifdef HAVE_XMU |
|
|
207 | RSTRG (Rs_pointerShape, "pointerShape", "string"), |
|
|
208 | #endif |
205 | /* fonts: command-line option = resource name */ |
209 | /* fonts: command-line option = resource name */ |
206 | STRG (Rs_font, "font", "fn", "fontname", "normal text font"), |
210 | STRG (Rs_font, "font", "fn", "fontname", "normal text font"), |
207 | #if ENABLE_STYLES |
211 | #if ENABLE_STYLES |
208 | STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"), |
212 | STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"), |
209 | STRG (Rs_italicFont, "italicFont", "fi", "fontname", "italic font"), |
213 | STRG (Rs_italicFont, "italicFont", "fi", "fontname", "italic font"), |
… | |
… | |
624 | return 0; |
628 | return 0; |
625 | } |
629 | } |
626 | |
630 | |
627 | /*}}} */ |
631 | /*}}} */ |
628 | |
632 | |
629 | #ifndef NO_RESOURCES |
|
|
630 | /*----------------------------------------------------------------------*/ |
633 | /*----------------------------------------------------------------------*/ |
631 | |
634 | |
632 | # ifdef KEYSYM_RESOURCE |
635 | #ifdef KEYSYM_RESOURCE |
633 | static void |
636 | static void |
634 | rxvt_define_key (rxvt_term *term, const char *k, const char *v) |
637 | rxvt_define_key (rxvt_term *term, const char *k, const char *v) |
635 | { |
638 | { |
636 | term->bind_action (k, v); |
639 | term->bind_action (k, v); |
637 | } |
640 | } |
… | |
… | |
641 | * quarks will be something like |
644 | * quarks will be something like |
642 | * "rxvt" "keysym" "0xFF01" |
645 | * "rxvt" "keysym" "0xFF01" |
643 | * value will be a string |
646 | * value will be a string |
644 | */ |
647 | */ |
645 | static int |
648 | static int |
646 | rxvt_keysym_enumerate_helper ( |
649 | rxvt_enumerate_helper ( |
647 | XrmDatabase *database ecb_unused, |
650 | XrmDatabase *database ecb_unused, |
648 | XrmBindingList bindings ecb_unused, |
651 | XrmBindingList bindings ecb_unused, |
649 | XrmQuarkList quarks, |
652 | XrmQuarkList quarks, |
650 | XrmRepresentation *type ecb_unused, |
653 | XrmRepresentation *type ecb_unused, |
651 | XrmValue *value, |
654 | XrmValue *value, |
… | |
… | |
706 | { "4", 1, Mod4Mask }, |
709 | { "4", 1, Mod4Mask }, |
707 | { "5", 1, Mod5Mask }, |
710 | { "5", 1, Mod5Mask }, |
708 | }; |
711 | }; |
709 | |
712 | |
710 | int |
713 | int |
711 | rxvt_term::bind_action (const char *str, const char *arg) |
714 | rxvt_term::parse_keysym (const char *str, unsigned int &state) |
712 | { |
715 | { |
713 | int sym; |
716 | int sym; |
714 | unsigned int state = 0; |
|
|
715 | const char *key = strrchr (str, '-'); |
717 | const char *key = strrchr (str, '-'); |
|
|
718 | |
|
|
719 | state = 0; |
716 | |
720 | |
717 | if (!key) |
721 | if (!key) |
718 | key = str; |
722 | key = str; |
719 | else |
723 | else |
720 | key++; |
724 | key++; |
721 | |
725 | |
722 | // string or key is empty |
726 | // string or key is empty |
723 | if (*arg == '\0' || *key == '\0') |
727 | if (*key == '\0') |
724 | return -1; |
728 | return -1; |
725 | |
729 | |
726 | // parse modifiers |
730 | // parse modifiers |
727 | while (str < key) |
731 | while (str < key) |
728 | { |
732 | { |
… | |
… | |
753 | sym = strtol (str, &end, 16); |
757 | sym = strtol (str, &end, 16); |
754 | if (*end) |
758 | if (*end) |
755 | return -1; |
759 | return -1; |
756 | } |
760 | } |
757 | |
761 | |
|
|
762 | return sym; |
|
|
763 | } |
|
|
764 | |
|
|
765 | int |
|
|
766 | rxvt_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 | |
758 | wchar_t *ws = rxvt_mbstowcs (arg); |
774 | wchar_t *ws = rxvt_mbstowcs (arg); |
759 | 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))) |
760 | keyboard->register_action (sym, state, ws); |
776 | keyboard->register_action (sym, state, ws); |
761 | |
777 | |
762 | free (ws); |
778 | free (ws); |
763 | return 1; |
779 | return 1; |
764 | } |
780 | } |
765 | |
781 | |
766 | # endif /* KEYSYM_RESOURCE */ |
782 | #endif /* KEYSYM_RESOURCE */ |
767 | #endif /* NO_RESOURCES */ |
|
|
768 | |
783 | |
769 | static char * |
784 | static char * |
770 | get_res (XrmDatabase database, const char *program, const char *option) |
785 | get_res (XrmDatabase database, const char *program, const char *option) |
771 | { |
786 | { |
772 | char resource[512]; |
787 | char resource[512]; |
… | |
… | |
844 | } |
859 | } |
845 | #endif /* NO_RESOURCES */ |
860 | #endif /* NO_RESOURCES */ |
846 | } |
861 | } |
847 | |
862 | |
848 | void |
863 | void |
849 | rxvt_term::enumerate_keysym_resources (void (*cb)(rxvt_term *, const char *, const char *)) |
864 | rxvt_term::enumerate_resources (void (*cb)(rxvt_term *, const char *, const char *), const char *name_p, const char *class_p) |
850 | { |
865 | { |
851 | #ifndef NO_RESOURCES |
|
|
852 | /* |
866 | /* |
853 | * [R5 or later]: enumerate the resource database |
867 | * [R5 or later]: enumerate the resource database |
854 | */ |
868 | */ |
855 | # ifdef KEYSYM_RESOURCE |
869 | #ifdef KEYSYM_RESOURCE |
856 | void *closure[2] = { |
870 | void *closure[2] = { |
857 | (void *)this, |
871 | (void *)this, |
858 | (void *)cb, |
872 | (void *)cb, |
859 | }; |
873 | }; |
860 | |
874 | |
861 | XrmDatabase database = XrmGetDatabase (dpy); |
875 | XrmDatabase database = XrmGetDatabase (dpy); |
862 | XrmName name_prefix[3]; |
876 | XrmName name_prefix[3]; |
863 | XrmClass class_prefix[3]; |
877 | XrmClass class_prefix[3]; |
864 | |
878 | |
865 | name_prefix[0] = XrmStringToName (rs[Rs_name]); |
879 | name_prefix[1] = name_p ? XrmStringToName (name_p) : NULLQUARK; |
866 | name_prefix[1] = XrmStringToName ("keysym"); |
|
|
867 | name_prefix[2] = NULLQUARK; |
880 | name_prefix[2] = NULLQUARK; |
868 | class_prefix[0] = XrmStringToName (RESCLASS); |
881 | class_prefix[1] = class_p ? XrmStringToName (class_p) : NULLQUARK; |
869 | class_prefix[1] = XrmStringToName ("Keysym"); |
|
|
870 | class_prefix[2] = NULLQUARK; |
882 | class_prefix[2] = NULLQUARK; |
871 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
883 | |
872 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
|
|
873 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
|
|
874 | # ifdef RESFALLBACK |
884 | # ifdef RESFALLBACK |
875 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); |
885 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); |
876 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
886 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
877 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
887 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
878 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
888 | XrmEnumOneLevel, rxvt_enumerate_helper, (XPointer)closure); |
879 | # endif |
|
|
880 | # endif |
889 | # endif |
881 | |
890 | |
882 | #endif /* NO_RESOURCES */ |
891 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); |
|
|
892 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
|
|
893 | XrmEnumOneLevel, rxvt_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_enumerate_helper, (XPointer)closure); |
|
|
898 | #endif |
883 | } |
899 | } |
884 | |
900 | |
885 | void |
901 | void |
886 | rxvt_term::extract_keysym_resources () |
902 | rxvt_term::extract_keysym_resources () |
887 | { |
903 | { |
|
|
904 | #ifdef KEYSYM_RESOURCE |
888 | enumerate_keysym_resources (rxvt_define_key); |
905 | enumerate_keysym_resources (rxvt_define_key); |
|
|
906 | #endif |
889 | } |
907 | } |
890 | |
908 | |
891 | /*----------------------- end-of-file (C source) -----------------------*/ |
909 | /*----------------------- end-of-file (C source) -----------------------*/ |
892 | |
910 | |