--- rxvt-unicode/src/xdefaults.C 2006/01/25 21:09:22 1.86 +++ rxvt-unicode/src/xdefaults.C 2006/02/20 22:42:01 1.95 @@ -1,4 +1,4 @@ -/*--------------------------------*-C-*---------------------------------* +/*----------------------------------------------------------------------* * File: xdefaults.C *----------------------------------------------------------------------* * @@ -23,12 +23,12 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *----------------------------------------------------------------------*/ -#include "../config.h" /* NECESSARY */ -#include "rxvt.h" /* NECESSARY */ +#include "../config.h" +#include "rxvt.h" #include "version.h" #ifdef KEYSYM_RESOURCE -#include "keyboard.h" +# include "keyboard.h" #endif /* place holders used for parsing command-line options */ @@ -36,7 +36,7 @@ #define Optflag_Boolean 0x80000000UL #define Optflag_mask 0x3fffffffUL -/*{{{ monolithic option/resource structure: */ +/* monolithic option/resource structure: */ /* * `string' options MUST have a usage argument * `switch' and `boolean' options have no argument @@ -213,12 +213,14 @@ #if ENABLE_XEMBED STRG (Rs_embed, NULL, "embed", "windowid", "window id to embed terminal in"), #endif +#if XFT + STRG (Rs_depth, "depth", "depth", "number", "depth of visual to request"), +#endif #if ENABLE_FRILLS RSTRG (Rs_transient_for, "transient-for", "windowid"), BOOL (Rs_override_redirect, "override-redirect", "override-redirect", Opt_override_redirect, "set override-redirect on the terminal window"), STRG (Rs_pty_fd, NULL, "pty-fd", "fileno", "file descriptor of pty to use"), BOOL (Rs_hold, "hold", "hold", Opt_hold, "retain window after shell exit"), - STRG (Rs_depth, "depth", "depth", "number", "depth of visual to request"), STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"), STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL), STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), @@ -266,7 +268,6 @@ #undef RSTRG #undef SWCH #undef BOOL -/*}}} */ static const char releasestring[] = "rxvt-unicode (" RXVTNAME ") v" VERSION " - released: " DATE "\n"; static const char optionsstring[] = "options: " @@ -323,33 +324,6 @@ #if defined(USE_XIM) "XIM," #endif - "scrollbars=" -#if !defined(HAVE_SCROLLBARS) - "NONE" -#else -# if defined(PLAIN_SCROLLBAR) - "plain" -# if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) - "+" -# endif -# endif -# if defined(RXVT_SCROLLBAR) - "rxvt" -# if defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) - "+" -# endif -# endif -# if defined(NEXT_SCROLLBAR) - "NeXT" -# if defined(XTERM_SCROLLBAR) - "+" -# endif -# endif -# if defined(XTERM_SCROLLBAR) - "xterm" -# endif -#endif - "," #if defined(NO_BACKSPACE_KEY) "no_backspace," #endif @@ -381,12 +355,42 @@ "pointerBlank," #endif #if defined(NO_RESOURCES) - "NoResources" + "NoResources," +#endif + "scrollbars=" +#if !defined(HAVE_SCROLLBARS) + "NONE" +#else +# if defined(PLAIN_SCROLLBAR) + "plain" +# if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) + "+" +# endif +# endif +# if defined(RXVT_SCROLLBAR) + "rxvt" +# if defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) + "+" +# endif +# endif +# if defined(NEXT_SCROLLBAR) + "NeXT" +# if defined(XTERM_SCROLLBAR) + "+" +# endif +# endif +# if defined(XTERM_SCROLLBAR) + "xterm" +# endif #endif "\nUsage: "; /* Usage */ #define INDENT 18 +const char rxvt_term::resval_undef [] = ""; +const char rxvt_term::resval_on [] = "on"; +const char rxvt_term::resval_off [] = "off"; + /*{{{ usage: */ /*----------------------------------------------------------------------*/ static void @@ -404,7 +408,7 @@ for (col = 1, i = 0; i < optList_size; i++) if (optList[i].desc != NULL) { - int len = 0; + int len = 0; if (!optList_isBool (i)) { @@ -481,8 +485,7 @@ void rxvt_term::get_options (int argc, const char *const *argv) { - int i, bad_option = 0; - static const char On[3] = "ON", Off[4] = "OFF"; + int i, bad_option = 0; for (i = 1; i < argc; i++) { @@ -493,13 +496,15 @@ if (*opt == '-') { - flag = On; + flag = resval_on; + if (*++opt == '-') longopt = *opt++; /* long option */ } else if (*opt == '+') { - flag = Off; + flag = resval_off; + if (*++opt == '+') longopt = *opt++; /* long option */ } @@ -512,6 +517,7 @@ if (!strcmp (opt, "help")) rxvt_usage (longopt ? 2 : 1); + if (!strcmp (opt, "h")) rxvt_usage (0); @@ -525,7 +531,7 @@ if (entry < optList_size) { if (optList_isReverse (entry)) - flag = flag == On ? Off : On; + flag = flag == resval_on ? resval_off : resval_on; if (optList_strlen (entry)) { @@ -536,12 +542,16 @@ */ if (optList[entry].doff != -1) - rs[optList[entry].doff] = flag == On && argv[i+1] - ? argv[++i] : 0; + { + if (flag == resval_on && !argv [i+1]) + rxvt_fatal ("option '%s' needs an argument, aborting.\n", argv [i]); + + rs[optList[entry].doff] = flag == resval_on ? argv[++i] : resval_undef; + } } else { /* boolean value */ - set_option (optList[entry].flag & Optflag_mask, flag == On); + set_option (optList[entry].flag & Optflag_mask, flag == resval_on); if (optList[entry].doff != -1) rs[optList[entry].doff] = flag; @@ -766,7 +776,7 @@ const char * rxvt_term::x_resource (const char *name) { - XrmDatabase database = XrmGetDatabase (xdisp); + XrmDatabase database = XrmGetDatabase (dpy); const char *p = get_res (database, rs[Rs_name], name); const char *p0 = get_res (database, "!INVALIDPROGRAMMENAMEDONTMATCH!", name); @@ -828,7 +838,7 @@ * [R5 or later]: enumerate the resource database */ # ifdef KEYSYM_RESOURCE - XrmDatabase database = XrmGetDatabase (xdisp); + XrmDatabase database = XrmGetDatabase (dpy); XrmName name_prefix[3]; XrmClass class_prefix[3];