--- rxvt-unicode/src/xdefaults.C 2011/12/02 09:03:43 1.159 +++ rxvt-unicode/src/xdefaults.C 2012/05/25 08:27:47 1.164 @@ -36,6 +36,7 @@ #define Optflag_Reverse 1 #define Optflag_Boolean 2 #define Optflag_Switch 4 +#define Optflag_Info 8 /* monolithic option/resource structure: */ /* @@ -46,7 +47,10 @@ /* INFO () - descriptive information only */ #define INFO(opt, arg, desc) \ - {0, 0, -1, NULL, (opt), (arg), (desc)} + {0, Optflag_Info, -1, NULL, (opt), (arg), (desc)} + +#define RINFO(kw, arg) \ + {0, Optflag_Info, -1, (kw), NULL, (arg), NULL} /* STRG () - command-line option, with/without resource */ #define STRG(rsp, kw, opt, arg, desc) \ @@ -71,6 +75,8 @@ (optList[i].flag & Optflag_Boolean) #define optList_isReverse(i) \ (optList[i].flag & Optflag_Reverse) +#define optList_isInfo(i) \ + (optList[i].flag & Optflag_Info) static const struct { @@ -266,13 +272,17 @@ BOOL (Rs_iso14755, "iso14755", NULL, Opt_iso14755, 0, NULL), BOOL (Rs_iso14755_52, "iso14755_52", NULL, Opt_iso14755_52, 0, NULL), #endif -#ifdef HAVE_AFTERIMAGE - STRG (Rs_blendtype, "blendType", "blt", "string", "background image blending type - alpha, tint, etc..."), +#ifndef NO_RESOURCES + RINFO ("xrm", "string"), +#endif +#ifdef KEYSYM_RESOURCE + RINFO ("keysym.sym", "keysym"), #endif INFO ("e", "command arg ...", "command to execute") }; #undef INFO +#undef RINFO #undef STRG #undef RSTRG #undef SWCH @@ -325,9 +335,6 @@ "transparent," "tint," #endif -#if HAVE_AFTERIMAGE - "afterimage," -#endif #if HAVE_PIXBUF "pixbuf," #endif @@ -452,11 +459,6 @@ optList[i].kw, (INDENT - strlen (optList[i].kw)), "", /* XXX */ (optList_isBool (i) ? "boolean" : optList[i].arg)); -#ifdef KEYSYM_RESOURCE - rxvt_log (" " "keysym.sym" ": %*s%s\n", - (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */ - "keysym"); -#endif rxvt_log ("\n -help to list options"); break; } @@ -468,7 +470,7 @@ /*}}} */ /*{{{ get command-line options before getting resources */ -void +const char ** rxvt_term::get_options (int argc, const char *const *argv) { int i, bad_option = 0; @@ -515,7 +517,8 @@ && optList[entry].opt && !strcmp (opt, optList[entry].opt))) break; - if (entry < ecb_array_length (optList)) + if (entry < ecb_array_length (optList) + && !optList_isInfo (entry)) { if (optList_isReverse (entry)) flag = !flag; @@ -563,6 +566,13 @@ } } #endif + else if (!strcmp (opt, "e")) + { + if (i+1 == argc) + rxvt_fatal ("option '-e' requires an argument, aborting.\n"); + + return (const char **)argv + i + 1; + } else { bad_option = 1; @@ -572,6 +582,8 @@ if (bad_option) rxvt_usage (0); + + return 0; } /*}}} */ @@ -750,7 +762,6 @@ */ for (int entry = 0; entry < ecb_array_length (optList); entry++) { - int s; const char *kw = optList[entry].kw; if (kw == NULL || rs[optList[entry].doff] != NULL) @@ -766,10 +777,7 @@ if (optList_isBool (entry)) { - s = strcasecmp (p, "TRUE") == 0 - || strcasecmp (p, "YES") == 0 - || strcasecmp (p, "ON") == 0 - || strcasecmp (p, "1") == 0; + bool s = parse_bool_resource (p); if (optList_isReverse (entry)) s = !s; @@ -784,33 +792,39 @@ void rxvt_term::extract_keysym_resources () { -#ifndef NO_RESOURCES +#if !defined NO_RESOURCES && defined KEYSYM_RESOURCE + find_resources ("keysym", "Keysym", XrmEnumOneLevel, rxvt_define_key); +#endif +} + +#if !defined NO_RESOURCES && (defined KEYSYM_RESOURCE || defined BG_IMAGE_FROM_FILE) +void +rxvt_term::find_resources (const char *n_prefix, const char *c_prefix, int mode, + Bool (*proc)(XrmDatabase *, XrmBindingList, XrmQuarkList, XrmRepresentation *, XrmValue *, XPointer)) +{ /* * [R5 or later]: enumerate the resource database */ -# ifdef KEYSYM_RESOURCE XrmDatabase database = XrmGetDatabase (dpy); XrmName name_prefix[3]; XrmClass class_prefix[3]; name_prefix[0] = XrmStringToName (rs[Rs_name]); - name_prefix[1] = XrmStringToName ("keysym"); + name_prefix[1] = XrmStringToName (n_prefix); name_prefix[2] = NULLQUARK; class_prefix[0] = XrmStringToName (RESCLASS); - class_prefix[1] = XrmStringToName ("Keysym"); + class_prefix[1] = XrmStringToName (c_prefix); class_prefix[2] = NULLQUARK; /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ XrmEnumerateDatabase (database, name_prefix, class_prefix, - XrmEnumOneLevel, rxvt_define_key, NULL); + mode, proc, NULL); # ifdef RESFALLBACK name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ XrmEnumerateDatabase (database, name_prefix, class_prefix, - XrmEnumOneLevel, rxvt_define_key, NULL); + mode, proc, NULL); # endif -# endif - -#endif /* NO_RESOURCES */ } +#endif /*----------------------- end-of-file (C source) -----------------------*/