--- rxvt-unicode/src/xdefaults.C 2006/01/11 02:13:56 1.78 +++ rxvt-unicode/src/xdefaults.C 2007/05/01 14:46:23 1.98 @@ -1,4 +1,4 @@ -/*--------------------------------*-C-*---------------------------------* +/*----------------------------------------------------------------------* * File: xdefaults.C *----------------------------------------------------------------------* * @@ -23,22 +23,19 @@ * 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 */ -#define Optflag_Reverse 0x40000000UL -#define Optflag_Boolean 0x80000000UL -#define Optflag_mask 0x3fffffffUL +#define Optflag_Reverse 1 +#define Optflag_Boolean 2 -/* #define DEBUG_RESOURCES */ - -/*{{{ monolithic option/resource structure: */ +/* monolithic option/resource structure: */ /* * `string' options MUST have a usage argument * `switch' and `boolean' options have no argument @@ -47,23 +44,23 @@ /* INFO () - descriptive information only */ #define INFO(opt, arg, desc) \ - {0, -1, NULL, (opt), (arg), (desc)} + {0, 0, -1, NULL, (opt), (arg), (desc)} /* STRG () - command-line option, with/without resource */ #define STRG(rsp, kw, opt, arg, desc) \ - {0, (rsp), (kw), (opt), (arg), (desc)} + {0, 0, (rsp), (kw), (opt), (arg), (desc)} /* RSTRG () - resource/long-option */ #define RSTRG(rsp, kw, arg) \ - {0, (rsp), (kw), NULL, (arg), NULL} + {0, 0, (rsp), (kw), NULL, (arg), NULL} /* BOOL () - regular boolean `-/+' flag */ -#define BOOL(rsp, kw, opt, flag, desc) \ - { (Optflag_Boolean | (flag)), (rsp), (kw), (opt), NULL, (desc)} +#define BOOL(rsp, kw, opt, option, flag, desc) \ + { option ## _idx, (Optflag_Boolean | (flag)), (rsp), (kw), (opt), NULL, (desc)} /* SWCH () - `-' flag */ -#define SWCH(opt, flag, desc) \ - { (flag), -1, NULL, (opt), NULL, (desc)} +#define SWCH(opt, option, flag, desc) \ + { option ## _idx, (flag), -1, NULL, (opt), NULL, (desc)} /* convenient macros */ #define optList_strlen(i) \ @@ -77,8 +74,9 @@ static const struct { - const unsigned long flag; /* Option flag */ - const int doff; /* data offset */ + const uint8_t index; /* Option index */ + const uint8_t flag; /* Option flag */ + const int16_t doff; /* resource value index or -1 */ const char *kw; /* keyword */ const char *opt; /* option */ const char *arg; /* argument */ @@ -90,28 +88,28 @@ STRG (Rs_term_name, "termName", "tn", "string", "value of the TERM environment variable"), STRG (Rs_geometry, NULL, "g", NULL, NULL), /* short form */ STRG (Rs_geometry, "geometry", "geometry", "geometry", "size (in characters) and position"), - SWCH ("C", Opt_console, "intercept console messages"), - SWCH ("iconic", Opt_iconic, "start iconic"), - SWCH ("ic", Opt_iconic, NULL), /* short form */ - BOOL (Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo, "reverse video"), - BOOL (Rs_loginShell, "loginShell", "ls", Opt_loginShell, "login shell"), - BOOL (Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, "jump scrolling"), - BOOL (Rs_pastableTabs, "pastableTabs", "ptab", Opt_pastableTabs, "tab characters are pastable"), + SWCH ("C", Opt_console, 0, "intercept console messages"), + SWCH ("iconic", Opt_iconic, 0, "start iconic"), + SWCH ("ic", Opt_iconic, 0, NULL), /* short form */ + BOOL (Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo, 0, "reverse video"), + BOOL (Rs_loginShell, "loginShell", "ls", Opt_loginShell, 0, "login shell"), + BOOL (Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, 0, "jump scrolling"), + BOOL (Rs_pastableTabs, "pastableTabs", "ptab", Opt_pastableTabs, 0, "tab characters are pastable"), #if HAVE_SCROLLBARS RSTRG (Rs_scrollstyle, "scrollstyle", "mode"), - BOOL (Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, "scrollbar"), - BOOL (Rs_scrollBar_right, "scrollBar_right", "sr", Opt_scrollBar_right, "scrollbar right"), - BOOL (Rs_scrollBar_floating, "scrollBar_floating", "st", Opt_scrollBar_floating, "scrollbar without a trough"), + BOOL (Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, 0, "scrollbar"), + BOOL (Rs_scrollBar_right, "scrollBar_right", "sr", Opt_scrollBar_right, 0, "scrollbar right"), + BOOL (Rs_scrollBar_floating, "scrollBar_floating", "st", Opt_scrollBar_floating, 0, "scrollbar without a trough"), RSTRG (Rs_scrollBar_align, "scrollBar_align", "mode"), STRG (Rs_scrollBar_thickness, "thickness", "sbt", "number", "scrollbar thickness/width in pixels"), #endif - BOOL (Rs_scrollTtyOutput, "scrollTtyOutput", NULL, Opt_scrollTtyOutput, NULL), - BOOL (Rs_scrollTtyOutput, NULL, "si", Optflag_Reverse | Opt_scrollTtyOutput, "scroll-on-tty-output inhibit"), - BOOL (Rs_scrollTtyKeypress, "scrollTtyKeypress", "sk", Opt_scrollTtyKeypress, "scroll-on-keypress"), - BOOL (Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer, "scroll-with-buffer"), + BOOL (Rs_scrollTtyOutput, "scrollTtyOutput", NULL, Opt_scrollTtyOutput, 0, NULL), + BOOL (Rs_scrollTtyOutput, NULL, "si", Opt_scrollTtyOutput, Optflag_Reverse, "scroll-on-tty-output inhibit"), + BOOL (Rs_scrollTtyKeypress, "scrollTtyKeypress", "sk", Opt_scrollTtyKeypress, 0, "scroll-on-keypress"), + BOOL (Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer, 0, "scroll-with-buffer"), #if TRANSPARENT - BOOL (Rs_transparent, "inheritPixmap", "ip", Opt_transparent, "inherit parent pixmap"), - SWCH ("tr", Opt_transparent, NULL), + BOOL (Rs_transparent, "inheritPixmap", "ip", Opt_transparent, 0, "inherit parent pixmap"), + SWCH ("tr", Opt_transparent, 0, NULL), # if TINTING STRG (Rs_color + Color_tint, "tintColor", "tint", "color", "tint color"), # endif @@ -121,31 +119,31 @@ STRG (Rs_color + Color_fade, "fadeColor", "fadecolor", "color", "target color for off-focus fading"), #endif #if TINTING - STRG (Rs_shade, "shading", "sh", "%", "shade background by x% when tinting."), + STRG (Rs_shade, "shading", "sh", "%", "shade background by x % when tinting."), #endif - BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, "utmp inhibit"), + BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, 0, "utmp inhibit"), #ifndef NO_BELL - BOOL (Rs_visualBell, "visualBell", "vb", Opt_visualBell, "visual bell"), + BOOL (Rs_visualBell, "visualBell", "vb", Opt_visualBell, 0, "visual bell"), # if ! defined(NO_MAPALERT) && defined(MAPALERT_OPTION) - BOOL (Rs_mapAlert, "mapAlert", NULL, Opt_mapAlert, NULL), + BOOL (Rs_mapAlert, "mapAlert", NULL, Opt_mapAlert, 0, NULL), # endif #endif #ifdef META8_OPTION - BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, NULL), + BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, 0, NULL), #endif #ifdef MOUSE_WHEEL - BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, NULL), + BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, 0, NULL), #endif #if ENABLE_FRILLS - BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, "triple click word selection"), - BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, "enable possibly insecure escape sequences"), - BOOL (Rs_cursorUnderline, "cursorUnderline", "uc", Opt_cursorUnderline, "underline cursor"), + BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, 0, "triple click word selection"), + BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, 0, "enable possibly insecure escape sequences"), + BOOL (Rs_cursorUnderline, "cursorUnderline", "uc", Opt_cursorUnderline, 0, "underline cursor"), #endif #if CURSOR_BLINK - BOOL (Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"), + BOOL (Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, 0, "blinking cursor"), #endif #ifdef POINTER_BLANK - BOOL (Rs_pointerBlank, "pointerBlank", "pb", Opt_pointerBlank, "switch off pointer after delay"), + BOOL (Rs_pointerBlank, "pointerBlank", "pb", Opt_pointerBlank, 0, "switch off pointer after delay"), #endif STRG (Rs_color + Color_bg, "background", "bg", "color", "background color"), STRG (Rs_color + Color_fg, "foreground", "fg", "color", "foreground color"), @@ -189,14 +187,9 @@ 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"), -#if defined (XPM_BACKGROUND) || (MENUBAR_MAX) - RSTRG (Rs_path, "path", "search path"), -#endif /* defined (XPM_BACKGROUND) || (MENUBAR_MAX) */ #ifdef XPM_BACKGROUND + RSTRG (Rs_path, "path", "search path"), STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"), -#endif /* XPM_BACKGROUND */ -#if (MENUBAR_MAX) - RSTRG (Rs_menu, "menu", "name[;tag]"), #endif /* fonts: command-line option = resource name */ STRG (Rs_font, "font", "fn", "fontname", "normal text font"), @@ -204,7 +197,7 @@ STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"), STRG (Rs_italicFont, "italicFont", "fi", "fontname", "italic font"), STRG (Rs_boldItalicFont, "boldItalicFont", "fbi", "fontname", "bold italic font"), - BOOL (Rs_intensityStyles, "intensityStyles", "is", Opt_intensityStyles, "font styles imply intensity changes"), + BOOL (Rs_intensityStyles, "intensityStyles", "is", Opt_intensityStyles, 0, "font styles imply intensity changes"), #endif #ifdef USE_XIM STRG (Rs_inputMethod, "inputMethod", "im", "name", "name of input method"), @@ -220,16 +213,20 @@ #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, 0, "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"), + BOOL (Rs_hold, "hold", "hold", Opt_hold, 0, "retain window after shell exit"), 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), STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"), - BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, "borderless window"), - BOOL (Rs_skipBuiltinGlyphs, "skipBuiltinGlyphs", "sbg", Opt_skipBuiltinGlyphs, "do not use internal glyphs"), + BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, 0, "borderless window"), + BOOL (Rs_skipBuiltinGlyphs, "skipBuiltinGlyphs", "sbg", Opt_skipBuiltinGlyphs, 0, "do not use internal glyphs"), STRG (Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows"), #endif #ifdef POINTER_BLANK @@ -251,8 +248,8 @@ #endif /* CUTCHAR_RESOURCE */ RSTRG (Rs_answerbackstring, "answerbackString", "string"), #ifndef NO_SECONDARY_SCREEN - BOOL (Rs_secondaryScreen, "secondaryScreen", "ssc", Opt_secondaryScreen, "enable secondary screen"), - BOOL (Rs_secondaryScroll, "secondaryScroll", "ssr", Opt_secondaryScroll, "enable secondary screen scroll"), + BOOL (Rs_secondaryScreen, "secondaryScreen", "ssc", Opt_secondaryScreen, 0, "enable secondary screen"), + BOOL (Rs_secondaryScroll, "secondaryScroll", "ssr", Opt_secondaryScroll, 0, "enable secondary screen scroll"), #endif #if ENABLE_PERL RSTRG (Rs_perl_lib, "perl-lib", "string"), //, "colon-separated directories with extension scripts"),TODO @@ -271,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: " @@ -325,42 +321,9 @@ #if TINTING "tint," #endif -#if defined(UTMP_SUPPORT) - "utmp," -#endif -#if defined(MENUBAR) - "menubar," -#endif #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 @@ -370,15 +333,9 @@ #if EIGHT_BIT_CONTROLS "8bitctrls," #endif -#if !defined(NO_STRINGS) - "strings," -#endif #if defined(ENABLE_FRILLS) "frills," #endif -#if defined(PREFER_24BIT) - "24bit," -#endif #if defined(SELECTION_SCROLLING) "selectionscrolling," #endif @@ -398,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 @@ -421,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)) { @@ -498,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++) { @@ -507,18 +493,18 @@ const char *flag, *opt; opt = argv[i]; -#ifdef DEBUG_RESOURCES - fprintf (stderr, "argv[%d] = %s: ", i, opt); -#endif + 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 */ } @@ -531,6 +517,7 @@ if (!strcmp (opt, "help")) rxvt_usage (longopt ? 2 : 1); + if (!strcmp (opt, "h")) rxvt_usage (0); @@ -544,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)) { @@ -555,16 +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 */ -#ifdef DEBUG_RESOURCES - fprintf (stderr, "boolean (%s,%s) = %s\n", - optList[entry].opt, optList[entry].kw, flag); -#endif - set_option (optList[entry].flag & Optflag_mask, flag == On); + set_option (1UL << optList[entry].index, flag == resval_on); if (optList[entry].doff != -1) rs[optList[entry].doff] = flag; @@ -606,12 +593,12 @@ */ /* ARGSUSED */ int -rxvt_define_key (XrmDatabase *database __attribute__((unused)), - XrmBindingList bindings __attribute__((unused)), +rxvt_define_key (XrmDatabase *database UNUSED, + XrmBindingList bindings UNUSED, XrmQuarkList quarks, - XrmRepresentation *type __attribute__((unused)), + XrmRepresentation *type UNUSED, XrmValue *value, - XPointer closure __attribute__((unused))) + XPointer closure UNUSED) { int last; @@ -789,7 +776,7 @@ const char * rxvt_term::x_resource (const char *name) { - XrmDatabase database = XrmGetDatabase (display->display); + XrmDatabase database = XrmGetDatabase (dpy); const char *p = get_res (database, rs[Rs_name], name); const char *p0 = get_res (database, "!INVALIDPROGRAMMENAMEDONTMATCH!", name); @@ -842,7 +829,7 @@ if (optList_isReverse (entry)) s = !s; - set_option (optList[entry].flag & Optflag_mask, s); + set_option (1UL << optList[entry].index, s); } } } @@ -851,7 +838,7 @@ * [R5 or later]: enumerate the resource database */ # ifdef KEYSYM_RESOURCE - XrmDatabase database = XrmGetDatabase (display->display); + XrmDatabase database = XrmGetDatabase (dpy); XrmName name_prefix[3]; XrmClass class_prefix[3];