… | |
… | |
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"), |
… | |
… | |
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"), |
… | |
… | |
625 | return 0; |
617 | return 0; |
626 | } |
618 | } |
627 | |
619 | |
628 | /*}}} */ |
620 | /*}}} */ |
629 | |
621 | |
630 | #ifndef NO_RESOURCES |
|
|
631 | /*----------------------------------------------------------------------*/ |
622 | /*----------------------------------------------------------------------*/ |
632 | |
623 | |
633 | # ifdef KEYSYM_RESOURCE |
624 | #ifdef KEYSYM_RESOURCE |
634 | static void |
625 | static void |
635 | 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) |
636 | { |
627 | { |
637 | term->bind_action (k, v); |
628 | term->bind_action (k, v); |
638 | } |
629 | } |
… | |
… | |
642 | * quarks will be something like |
633 | * quarks will be something like |
643 | * "rxvt" "keysym" "0xFF01" |
634 | * "rxvt" "keysym" "0xFF01" |
644 | * value will be a string |
635 | * value will be a string |
645 | */ |
636 | */ |
646 | static int |
637 | static int |
647 | rxvt_keysym_enumerate_helper ( |
638 | rxvt_enumerate_helper ( |
648 | XrmDatabase *database ecb_unused, |
639 | XrmDatabase *database ecb_unused, |
649 | XrmBindingList bindings ecb_unused, |
640 | XrmBindingList bindings ecb_unused, |
650 | XrmQuarkList quarks, |
641 | XrmQuarkList quarks, |
651 | XrmRepresentation *type ecb_unused, |
642 | XrmRepresentation *type ecb_unused, |
652 | XrmValue *value, |
643 | XrmValue *value, |
… | |
… | |
707 | { "4", 1, Mod4Mask }, |
698 | { "4", 1, Mod4Mask }, |
708 | { "5", 1, Mod5Mask }, |
699 | { "5", 1, Mod5Mask }, |
709 | }; |
700 | }; |
710 | |
701 | |
711 | int |
702 | int |
712 | rxvt_term::bind_action (const char *str, const char *arg) |
703 | rxvt_term::parse_keysym (const char *str, unsigned int &state) |
713 | { |
704 | { |
714 | int sym; |
705 | int sym; |
715 | unsigned int state = 0; |
|
|
716 | const char *key = strrchr (str, '-'); |
706 | const char *key = strrchr (str, '-'); |
|
|
707 | |
|
|
708 | state = 0; |
717 | |
709 | |
718 | if (!key) |
710 | if (!key) |
719 | key = str; |
711 | key = str; |
720 | else |
712 | else |
721 | key++; |
713 | key++; |
722 | |
714 | |
723 | // string or key is empty |
715 | // string or key is empty |
724 | if (*arg == '\0' || *key == '\0') |
716 | if (*key == '\0') |
725 | return -1; |
717 | return -1; |
726 | |
718 | |
727 | // parse modifiers |
719 | // parse modifiers |
728 | while (str < key) |
720 | while (str < key) |
729 | { |
721 | { |
… | |
… | |
754 | sym = strtol (str, &end, 16); |
746 | sym = strtol (str, &end, 16); |
755 | if (*end) |
747 | if (*end) |
756 | return -1; |
748 | return -1; |
757 | } |
749 | } |
758 | |
750 | |
|
|
751 | return sym; |
|
|
752 | } |
|
|
753 | |
|
|
754 | int |
|
|
755 | rxvt_term::bind_action (const char *str, const char *arg) |
|
|
756 | { |
|
|
757 | int sym; |
|
|
758 | unsigned int state; |
|
|
759 | |
|
|
760 | if (*arg == '\0' || (sym = parse_keysym (str, state)) == -1) |
|
|
761 | return -1; |
|
|
762 | |
759 | wchar_t *ws = rxvt_mbstowcs (arg); |
763 | wchar_t *ws = rxvt_mbstowcs (arg); |
|
|
764 | 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); |
765 | keyboard->register_action (sym, state, ws); |
761 | |
766 | |
762 | free (ws); |
767 | free (ws); |
763 | return 1; |
768 | return 1; |
764 | } |
769 | } |
765 | |
770 | |
766 | # endif /* KEYSYM_RESOURCE */ |
771 | #endif /* KEYSYM_RESOURCE */ |
767 | #endif /* NO_RESOURCES */ |
|
|
768 | |
772 | |
769 | static char * |
773 | static char * |
770 | get_res (XrmDatabase database, const char *program, const char *option) |
774 | get_res (XrmDatabase database, const char *program, const char *option) |
771 | { |
775 | { |
772 | char resource[512]; |
776 | char resource[512]; |
… | |
… | |
844 | } |
848 | } |
845 | #endif /* NO_RESOURCES */ |
849 | #endif /* NO_RESOURCES */ |
846 | } |
850 | } |
847 | |
851 | |
848 | void |
852 | void |
849 | rxvt_term::enumerate_keysym_resources (void (*cb)(rxvt_term *, const char *, const char *)) |
853 | rxvt_term::enumerate_resources (void (*cb)(rxvt_term *, const char *, const char *), const char *name_p, const char *class_p) |
850 | { |
854 | { |
851 | #ifndef NO_RESOURCES |
|
|
852 | /* |
855 | /* |
853 | * [R5 or later]: enumerate the resource database |
856 | * [R5 or later]: enumerate the resource database |
854 | */ |
857 | */ |
855 | # ifdef KEYSYM_RESOURCE |
858 | #ifdef KEYSYM_RESOURCE |
856 | void *closure[2] = { |
859 | void *closure[2] = { |
857 | (void *)this, |
860 | (void *)this, |
858 | (void *)cb, |
861 | (void *)cb, |
859 | }; |
862 | }; |
860 | |
863 | |
861 | XrmDatabase database = XrmGetDatabase (dpy); |
864 | XrmDatabase database = XrmGetDatabase (dpy); |
862 | XrmName name_prefix[3]; |
865 | XrmName name_prefix[3]; |
863 | XrmClass class_prefix[3]; |
866 | XrmClass class_prefix[3]; |
864 | |
867 | |
865 | name_prefix[0] = XrmStringToName (rs[Rs_name]); |
868 | name_prefix[1] = name_p ? XrmStringToName (name_p) : NULLQUARK; |
866 | name_prefix[1] = XrmStringToName ("keysym"); |
|
|
867 | name_prefix[2] = NULLQUARK; |
869 | name_prefix[2] = NULLQUARK; |
868 | class_prefix[0] = XrmStringToName (RESCLASS); |
870 | class_prefix[1] = class_p ? XrmStringToName (class_p) : NULLQUARK; |
869 | class_prefix[1] = XrmStringToName ("Keysym"); |
|
|
870 | class_prefix[2] = NULLQUARK; |
871 | class_prefix[2] = NULLQUARK; |
871 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
872 | |
872 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
|
|
873 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
|
|
874 | # ifdef RESFALLBACK |
873 | # ifdef RESFALLBACK |
875 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); |
874 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); |
876 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
875 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
877 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
876 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
878 | XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); |
877 | XrmEnumOneLevel, rxvt_enumerate_helper, (XPointer)closure); |
879 | # endif |
|
|
880 | # endif |
878 | # endif |
881 | |
879 | |
882 | #endif /* NO_RESOURCES */ |
880 | name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); |
|
|
881 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
|
|
882 | XrmEnumOneLevel, rxvt_enumerate_helper, (XPointer)closure); |
|
|
883 | |
|
|
884 | name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]); |
|
|
885 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
|
|
886 | XrmEnumOneLevel, rxvt_enumerate_helper, (XPointer)closure); |
|
|
887 | #endif |
883 | } |
888 | } |
884 | |
889 | |
885 | void |
890 | void |
886 | rxvt_term::extract_keysym_resources () |
891 | rxvt_term::extract_keysym_resources () |
887 | { |
892 | { |
|
|
893 | #ifdef KEYSYM_RESOURCE |
888 | enumerate_keysym_resources (rxvt_define_key); |
894 | enumerate_keysym_resources (rxvt_define_key); |
|
|
895 | #endif |
889 | } |
896 | } |
890 | |
897 | |
891 | /*----------------------- end-of-file (C source) -----------------------*/ |
898 | /*----------------------- end-of-file (C source) -----------------------*/ |
892 | |
899 | |