--- rxvt-unicode/src/xdefaults.C 2012/02/04 21:47:06 1.162 +++ rxvt-unicode/src/xdefaults.C 2012/06/05 19:32:29 1.166 @@ -194,7 +194,7 @@ STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"), -#ifdef BG_IMAGE_FROM_FILE +#if BG_IMAGE_FROM_FILE RSTRG (Rs_path, "path", "search path"), STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"), # if ENABLE_EWMH @@ -209,7 +209,7 @@ STRG (Rs_boldItalicFont, "boldItalicFont", "fbi", "fontname", "bold italic font"), BOOL (Rs_intensityStyles, "intensityStyles", "is", Opt_intensityStyles, 0, "font styles imply intensity changes"), #endif -#ifdef USE_XIM +#if USE_XIM STRG (Rs_inputMethod, "inputMethod", "im", "name", "name of input method"), STRG (Rs_preeditType, "preeditType", "pt", "style", "input style: style = OverTheSpot|OffTheSpot|Root"), STRG (Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"), @@ -394,8 +394,8 @@ /*{{{ usage: */ /*----------------------------------------------------------------------*/ -static void -rxvt_usage (int type) +void +rxvt_term::rxvt_usage (int type) { unsigned int i, col; @@ -413,9 +413,11 @@ if (optList[i].arg) len = strlen (optList[i].arg) + 1; + assert (optList[i].opt != NULL); len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2 : 0); col += len; + if (col > 79) { /* assume regular width */ @@ -424,6 +426,7 @@ } rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt); + if (optList[i].arg) rxvt_log (" %s]", optList[i].arg); else @@ -463,6 +466,14 @@ break; } +#if ENABLE_PERL + if (type) // do not initialise perl for type == 0, as perl does not have "short" options + { + rxvt_perl.init (this); + rxvt_perl.usage (type); + } +#endif + rxvt_log ("\n\n"); rxvt_exit_failure (); } @@ -575,8 +586,25 @@ } else { - bad_option = 1; - rxvt_warn ("\"%s\": unknown or malformed option.\n", opt); +#if ENABLE_PERL + rxvt_perl.init (this); + + if (int flags = rxvt_perl.resource (this, opt, true, longopt, flag, argv [i + 1])) + { + if ((!flags & rxvt_perl.RESOURCE_BOOLEAN)) + { + if (flag && i + 1 == argc) + rxvt_fatal ("option '%s' requires an argument, aborting.\n", argv [i]); + + ++i; + } + } + else +#endif + { + bad_option = 1; + rxvt_warn ("\"%s\": unknown or malformed option.\n", opt); + } } } @@ -762,7 +790,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) @@ -778,10 +805,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; @@ -796,33 +820,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) -----------------------*/