… | |
… | |
4 | * |
4 | * |
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-2004 Marc Lehmann <pcg@goof.com> |
9 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
10 | * |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by |
12 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2 of the License, or |
13 | * the Free Software Foundation; either version 2 of the License, or |
14 | * (at your option) any later version. |
14 | * (at your option) any later version. |
… | |
… | |
161 | RSTRG (Rs_color + minCOLOR + 3, "color3", "color"), |
161 | RSTRG (Rs_color + minCOLOR + 3, "color3", "color"), |
162 | RSTRG (Rs_color + minCOLOR + 4, "color4", "color"), |
162 | RSTRG (Rs_color + minCOLOR + 4, "color4", "color"), |
163 | RSTRG (Rs_color + minCOLOR + 5, "color5", "color"), |
163 | RSTRG (Rs_color + minCOLOR + 5, "color5", "color"), |
164 | RSTRG (Rs_color + minCOLOR + 6, "color6", "color"), |
164 | RSTRG (Rs_color + minCOLOR + 6, "color6", "color"), |
165 | RSTRG (Rs_color + minCOLOR + 7, "color7", "color"), |
165 | RSTRG (Rs_color + minCOLOR + 7, "color7", "color"), |
166 | #ifndef NO_BRIGHTCOLOR |
|
|
167 | RSTRG (Rs_color + minBrightCOLOR + 0, "color8", "color"), |
166 | RSTRG (Rs_color + minBrightCOLOR + 0, "color8", "color"), |
168 | RSTRG (Rs_color + minBrightCOLOR + 1, "color9", "color"), |
167 | RSTRG (Rs_color + minBrightCOLOR + 1, "color9", "color"), |
169 | RSTRG (Rs_color + minBrightCOLOR + 2, "color10", "color"), |
168 | RSTRG (Rs_color + minBrightCOLOR + 2, "color10", "color"), |
170 | RSTRG (Rs_color + minBrightCOLOR + 3, "color11", "color"), |
169 | RSTRG (Rs_color + minBrightCOLOR + 3, "color11", "color"), |
171 | RSTRG (Rs_color + minBrightCOLOR + 4, "color12", "color"), |
170 | RSTRG (Rs_color + minBrightCOLOR + 4, "color12", "color"), |
172 | RSTRG (Rs_color + minBrightCOLOR + 5, "color13", "color"), |
171 | RSTRG (Rs_color + minBrightCOLOR + 5, "color13", "color"), |
173 | RSTRG (Rs_color + minBrightCOLOR + 6, "color14", "color"), |
172 | RSTRG (Rs_color + minBrightCOLOR + 6, "color14", "color"), |
174 | RSTRG (Rs_color + minBrightCOLOR + 7, "color15", "color"), |
173 | RSTRG (Rs_color + minBrightCOLOR + 7, "color15", "color"), |
175 | #endif /* NO_BRIGHTCOLOR */ |
|
|
176 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
174 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
177 | RSTRG (Rs_color + Color_BD, "colorBD", "color"), |
175 | RSTRG (Rs_color + Color_BD, "colorBD", "color"), |
178 | RSTRG (Rs_color + Color_IT, "colorIT", "color"), |
176 | RSTRG (Rs_color + Color_IT, "colorIT", "color"), |
179 | RSTRG (Rs_color + Color_UL, "colorUL", "color"), |
177 | RSTRG (Rs_color + Color_UL, "colorUL", "color"), |
180 | RSTRG (Rs_color + Color_RV, "colorRV", "color"), |
178 | RSTRG (Rs_color + Color_RV, "colorRV", "color"), |
… | |
… | |
227 | STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"), |
225 | STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"), |
228 | #if ENABLE_XEMBED |
226 | #if ENABLE_XEMBED |
229 | STRG (Rs_embed, NULL, "embed", "windowid", "window id to embed terminal in"), |
227 | STRG (Rs_embed, NULL, "embed", "windowid", "window id to embed terminal in"), |
230 | #endif |
228 | #endif |
231 | #if ENABLE_FRILLS |
229 | #if ENABLE_FRILLS |
|
|
230 | RSTRG (Rs_transient_for, "transient-for", "windowid"), |
232 | STRG (Rs_pty_fd, NULL, "pty-fd", "fileno", "file descriptor of pty to use"), |
231 | STRG (Rs_pty_fd, NULL, "pty-fd", "fileno", "file descriptor of pty to use"), |
233 | BOOL (Rs_hold, "hold", "hold", Opt_hold, "retain window after shell exit"), |
232 | BOOL (Rs_hold, "hold", "hold", Opt_hold, "retain window after shell exit"), |
234 | STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"), |
233 | STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"), |
235 | STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL), |
234 | STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL), |
236 | STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), |
235 | STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), |
237 | STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"), |
236 | STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"), |
238 | BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, "borderless window"), |
237 | BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, "borderless window"), |
|
|
238 | BOOL (Rs_skipBuiltinGlyphs, "skipBuiltinGlyphs", "sbg", Opt_skipBuiltinGlyphs, "do not use internal glyphs"), |
239 | STRG (Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows"), |
239 | STRG (Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows"), |
240 | #endif |
240 | #endif |
241 | #ifdef POINTER_BLANK |
241 | #ifdef POINTER_BLANK |
242 | RSTRG (Rs_pointerBlankDelay, "pointerBlankDelay", "number"), |
242 | RSTRG (Rs_pointerBlankDelay, "pointerBlankDelay", "number"), |
243 | #endif |
243 | #endif |
… | |
… | |
259 | #ifndef NO_SECONDARY_SCREEN |
259 | #ifndef NO_SECONDARY_SCREEN |
260 | BOOL (Rs_secondaryScreen, "secondaryScreen", "ssc", Opt_secondaryScreen, "enable secondary screen"), |
260 | BOOL (Rs_secondaryScreen, "secondaryScreen", "ssc", Opt_secondaryScreen, "enable secondary screen"), |
261 | BOOL (Rs_secondaryScroll, "secondaryScroll", "ssr", Opt_secondaryScroll, "enable secondary screen scroll"), |
261 | BOOL (Rs_secondaryScroll, "secondaryScroll", "ssr", Opt_secondaryScroll, "enable secondary screen scroll"), |
262 | #endif |
262 | #endif |
263 | #if ENABLE_PERL |
263 | #if ENABLE_PERL |
264 | STRG (Rs_perl_lib, "perl-lib", 0, "string", "colon-separated directories with extension scripts"), |
264 | RSTRG (Rs_perl_lib, "perl-lib", "string"), //, "colon-separated directories with extension scripts"),TODO |
265 | STRG (Rs_perl_eval, "perl-eval", 0, "string", "code to be evaluated after all extensions have been loaded"), |
265 | RSTRG (Rs_perl_eval, "perl-eval", "perl-eval"), // "string", "code to be evaluated after all extensions have been loaded"),TODO |
|
|
266 | RSTRG (Rs_perl_ext_1, "perl-ext-common", "string"), //, "colon-separated list of perl extensions to enable"),TODO |
266 | STRG (Rs_perl_ext, "perl-ext", "pe", "string", "colon-sepaated list of perl extensions to enable"), |
267 | STRG (Rs_perl_ext_2, "perl-ext", "pe", "string", "colon-separated list of perl extensions to enable for this instance"), |
267 | #endif |
268 | #endif |
268 | #if 0 && TODO |
269 | #if 0 && TODO |
269 | #if !defined(NO_RESOURCES) && defined(USE_XGETDEFAULT) |
270 | #if !defined(NO_RESOURCES) && defined(USE_XGETDEFAULT) |
270 | INFO ("xrm", "string", "X resource"), |
271 | INFO ("xrm", "string", "X resource"), |
271 | #endif |
272 | #endif |
… | |
… | |
403 | #endif |
404 | #endif |
404 | #if defined(NO_RESOURCES) |
405 | #if defined(NO_RESOURCES) |
405 | "NoResources" |
406 | "NoResources" |
406 | #else |
407 | #else |
407 | # if defined(USE_XGETDEFAULT) |
408 | # if defined(USE_XGETDEFAULT) |
408 | "XGetDefaults" |
409 | "XGetDefault" |
409 | # else |
410 | # else |
410 | ".Xdefaults" |
411 | ".Xdefaults" |
411 | # endif |
412 | # endif |
412 | #endif |
413 | #endif |
413 | "\nUsage: "; /* Usage */ |
414 | "\nUsage: "; /* Usage */ |
… | |
… | |
572 | { /* boolean value */ |
573 | { /* boolean value */ |
573 | #ifdef DEBUG_RESOURCES |
574 | #ifdef DEBUG_RESOURCES |
574 | fprintf (stderr, "boolean (%s,%s) = %s\n", |
575 | fprintf (stderr, "boolean (%s,%s) = %s\n", |
575 | optList[entry].opt, optList[entry].kw, flag); |
576 | optList[entry].opt, optList[entry].kw, flag); |
576 | #endif |
577 | #endif |
577 | if (flag == On) |
|
|
578 | SET_OPTION (optList[entry].flag & Optflag_mask); |
578 | set_option (optList[entry].flag & Optflag_mask, flag == On); |
579 | else |
|
|
580 | CLR_OPTION (optList[entry].flag & Optflag_mask); |
|
|
581 | |
579 | |
582 | if (optList[entry].doff != -1) |
580 | if (optList[entry].doff != -1) |
583 | rs[optList[entry].doff] = flag; |
581 | rs[optList[entry].doff] = flag; |
584 | } |
582 | } |
585 | } |
583 | } |
… | |
… | |
694 | { |
692 | { |
695 | if ((n = rxvt_Str_match (str, "keysym.")) == 0) |
693 | if ((n = rxvt_Str_match (str, "keysym.")) == 0) |
696 | return 0; |
694 | return 0; |
697 | |
695 | |
698 | str += n; /* skip `keysym.' */ |
696 | str += n; /* skip `keysym.' */ |
699 | if ((pmodend = strchr (str, ':')) < str) |
697 | if (!(pmodend = strchr (str, ':'))) |
700 | return -1; |
698 | return -1; |
701 | } |
699 | } |
702 | else |
700 | else |
703 | pmodend = str + strlen(str); |
701 | pmodend = str + strlen(str); |
704 | |
702 | |
… | |
… | |
866 | || strcmp (str, "1") == 0; |
864 | || strcmp (str, "1") == 0; |
867 | |
865 | |
868 | if (optList_isReverse (entry)) |
866 | if (optList_isReverse (entry)) |
869 | s = !s; |
867 | s = !s; |
870 | |
868 | |
871 | if (s) |
|
|
872 | SET_OPTION (optList[entry].flag & Optflag_mask); |
869 | set_option (optList[entry].flag & Optflag_mask, s); |
873 | else |
|
|
874 | CLR_OPTION (optList[entry].flag & Optflag_mask); |
|
|
875 | } |
870 | } |
876 | } |
871 | } |
877 | |
872 | |
878 | break; |
873 | break; |
879 | } |
874 | } |
… | |
… | |
884 | } |
879 | } |
885 | |
880 | |
886 | /*}}} */ |
881 | /*}}} */ |
887 | # endif /* ! USE_XGETDEFAULT */ |
882 | # endif /* ! USE_XGETDEFAULT */ |
888 | #endif /* NO_RESOURCES */ |
883 | #endif /* NO_RESOURCES */ |
|
|
884 | |
|
|
885 | #ifdef USE_XGETDEFAULT |
|
|
886 | char *get_res (XrmDatabase database, const char *program, const char *option) |
|
|
887 | { |
|
|
888 | char resource[512]; |
|
|
889 | char *type; |
|
|
890 | XrmValue result; |
|
|
891 | |
|
|
892 | snprintf (resource, sizeof (resource), "%s.%s", program, option); |
|
|
893 | XrmGetResource (database, resource, resource, &type, &result); |
|
|
894 | |
|
|
895 | return result.addr; |
|
|
896 | } |
|
|
897 | #endif |
889 | |
898 | |
890 | /*{{{ read the resources files */ |
899 | /*{{{ read the resources files */ |
891 | /* |
900 | /* |
892 | * using XGetDefault () or the hand-rolled replacement |
901 | * using XGetDefault () or the hand-rolled replacement |
893 | */ |
902 | */ |
… | |
… | |
918 | /* |
927 | /* |
919 | * get resources using the X library function |
928 | * get resources using the X library function |
920 | */ |
929 | */ |
921 | int entry; |
930 | int entry; |
922 | |
931 | |
923 | # ifdef XrmEnumOneLevel |
|
|
924 | char *displayResource, *xe; |
932 | char *displayResource, *xe; |
925 | XrmName name_prefix[3]; |
933 | XrmName name_prefix[3]; |
926 | XrmClass class_prefix[3]; |
934 | XrmClass class_prefix[3]; |
927 | XrmDatabase database, rdb1; |
935 | XrmDatabase database, rdb1; |
928 | |
936 | |
929 | XrmInitialize (); |
|
|
930 | database = NULL; |
937 | database = NULL; |
931 | |
938 | |
932 | // for ordering, see for example http://www.faqs.org/faqs/Xt-FAQ/ Subject: 20 |
939 | // for ordering, see for example http://www.faqs.org/faqs/Xt-FAQ/ Subject: 20 |
933 | |
940 | |
934 | // 6. System wide per application default file. |
941 | // 6. System wide per application default file. |
… | |
… | |
995 | if ((rdb1 = XrmGetFileDatabase (fname))) |
1002 | if ((rdb1 = XrmGetFileDatabase (fname))) |
996 | XrmMergeDatabases (rdb1, &database); |
1003 | XrmMergeDatabases (rdb1, &database); |
997 | } |
1004 | } |
998 | } |
1005 | } |
999 | |
1006 | |
1000 | XrmSetDatabase (disp, database); |
1007 | xrmdatabase = database; |
1001 | # endif |
|
|
1002 | |
1008 | |
1003 | /* |
1009 | /* |
1004 | * Query resources for options that affect us |
1010 | * Query resources for options that affect us |
1005 | */ |
1011 | */ |
1006 | for (entry = 0; entry < optList_size; entry++) |
1012 | for (entry = 0; entry < optList_size; entry++) |
… | |
… | |
1010 | const char *kw = optList[entry].kw; |
1016 | const char *kw = optList[entry].kw; |
1011 | |
1017 | |
1012 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
1018 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
1013 | continue; /* previously set */ |
1019 | continue; /* previously set */ |
1014 | |
1020 | |
1015 | p = XGetDefault (disp, rs[Rs_name], kw); |
1021 | p = get_res (database, rs[Rs_name], kw); |
1016 | p0 = XGetDefault (disp, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); |
1022 | p0 = get_res (database, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); |
1017 | if (p == NULL || (p0 && strcmp (p, p0) == 0)) |
1023 | if (p == NULL || (p0 && strcmp (p, p0) == 0)) |
1018 | { |
1024 | { |
1019 | p = XGetDefault (disp, RESCLASS, kw); |
1025 | p = get_res (database, RESCLASS, kw); |
1020 | #ifdef RESFALLBACK |
1026 | #ifdef RESFALLBACK |
1021 | if (p == NULL || (p0 && strcmp (p, p0) == 0)) |
1027 | if (p == NULL || (p0 && strcmp (p, p0) == 0)) |
1022 | p = XGetDefault (disp, RESFALLBACK, kw); |
1028 | p = get_res (database, RESFALLBACK, kw); |
1023 | #endif |
1029 | #endif |
1024 | } |
1030 | } |
1025 | |
1031 | |
1026 | if (p == NULL && p0) |
1032 | if (p == NULL && p0) |
1027 | p = p0; |
1033 | p = p0; |
… | |
… | |
1038 | || strcasecmp (p, "1") == 0; |
1044 | || strcasecmp (p, "1") == 0; |
1039 | |
1045 | |
1040 | if (optList_isReverse (entry)) |
1046 | if (optList_isReverse (entry)) |
1041 | s = !s; |
1047 | s = !s; |
1042 | |
1048 | |
1043 | if (s) |
|
|
1044 | SET_OPTION (optList[entry].flag & Optflag_mask); |
1049 | set_option (optList[entry].flag & Optflag_mask, s); |
1045 | else |
|
|
1046 | CLR_OPTION (optList[entry].flag & Optflag_mask); |
|
|
1047 | } |
1050 | } |
1048 | } |
1051 | } |
1049 | } |
1052 | } |
1050 | |
1053 | |
1051 | /* |
1054 | /* |
… | |
… | |
1057 | name_prefix[2] = NULLQUARK; |
1060 | name_prefix[2] = NULLQUARK; |
1058 | class_prefix[0] = XrmStringToName (RESCLASS); |
1061 | class_prefix[0] = XrmStringToName (RESCLASS); |
1059 | class_prefix[1] = XrmStringToName ("Keysym"); |
1062 | class_prefix[1] = XrmStringToName ("Keysym"); |
1060 | class_prefix[2] = NULLQUARK; |
1063 | class_prefix[2] = NULLQUARK; |
1061 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
1064 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
1062 | XrmEnumerateDatabase (XrmGetDatabase (disp), name_prefix, class_prefix, |
1065 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
1063 | XrmEnumOneLevel, rxvt_define_key, NULL); |
1066 | XrmEnumOneLevel, rxvt_define_key, NULL); |
1064 | # ifdef RESFALLBACK |
1067 | # ifdef RESFALLBACK |
1065 | name_prefix[0] = XrmStringToName (RESFALLBACK); |
1068 | name_prefix[0] = XrmStringToName (RESFALLBACK); |
1066 | name_prefix[1] = XrmStringToName ("keysym"); |
1069 | name_prefix[1] = XrmStringToName ("keysym"); |
1067 | class_prefix[0] = XrmStringToName (RESFALLBACK); |
1070 | class_prefix[0] = XrmStringToName (RESFALLBACK); |
1068 | class_prefix[1] = XrmStringToName ("Keysym"); |
1071 | class_prefix[1] = XrmStringToName ("Keysym"); |
1069 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
1072 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
1070 | XrmEnumerateDatabase (XrmGetDatabase (disp), name_prefix, class_prefix, |
1073 | XrmEnumerateDatabase (database, name_prefix, class_prefix, |
1071 | XrmEnumOneLevel, rxvt_define_key, NULL); |
1074 | XrmEnumOneLevel, rxvt_define_key, NULL); |
1072 | # endif |
1075 | # endif |
1073 | # endif |
1076 | # endif |
1074 | |
1077 | |
1075 | # else /* USE_XGETDEFAULT */ |
1078 | # else /* USE_XGETDEFAULT */ |