--- rxvt-unicode/src/xdefaults.C 2004/08/03 22:19:51 1.29 +++ rxvt-unicode/src/xdefaults.C 2011/04/30 13:11:34 1.153 @@ -1,4 +1,4 @@ -/*--------------------------------*-C-*---------------------------------* +/*----------------------------------------------------------------------* * File: xdefaults.C *----------------------------------------------------------------------* * @@ -6,7 +6,8 @@ * Copyright (c) 1994 Robert Nation * - original version * Copyright (c) 1997,1998 mj olesen - * Copyright (c) 2003-2004 Marc Lehmann + * Copyright (c) 2003-2006 Marc Lehmann + * Copyright (c) 2007 Emanuele Giaquinta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,21 +23,21 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *----------------------------------------------------------------------*/ -/*----------------------------------------------------------------------* - * get resources from ~/.Xdefaults or ~/.Xresources with the memory-saving - * default or with XGetDefault() (#define USE_XGETDEFAULT) - *----------------------------------------------------------------------*/ -#include "../config.h" /* NECESSARY */ -#include "rxvt.h" /* NECESSARY */ +#include "../config.h" +#include "rxvt.h" #include "version.h" -#include "xdefaults.intpro" /* PROTOS for internal routines */ -/* #define DEBUG_RESOURCES */ +#ifdef KEYSYM_RESOURCE +# include "keyboard.h" +#endif -static const char *const xnames[2] = { ".Xdefaults", ".Xresources" }; +/* place holders used for parsing command-line options */ +#define Optflag_Reverse 1 +#define Optflag_Boolean 2 +#define Optflag_Switch 4 -/*{{{ monolithic option/resource structure: */ +/* monolithic option/resource structure: */ /* * `string' options MUST have a usage argument * `switch' and `boolean' options have no argument @@ -45,38 +46,37 @@ /* 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) \ - { (Opt_Boolean| (flag)), (rsp), (kw), (opt), NULL, (desc)} +#define BOOL(rsp, kw, opt, option, flag, desc) \ + { (option), (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), (Optflag_Switch | (flag)), -1, NULL, (opt), NULL, (desc)} /* convenient macros */ -#define optList_strlen(i) \ - (optList[i].flag ? 0 : (optList[i].arg ? STRLEN (optList[i].arg) : 1)) +#define optList_isString(i) \ + (optList[i].flag == 0) #define optList_isBool(i) \ - (optList[i].flag & Opt_Boolean) + (optList[i].flag & Optflag_Boolean) #define optList_isReverse(i) \ - (optList[i].flag & Opt_Reverse) -#define optList_size() \ - (sizeof (optList) / sizeof (optList[0])) + (optList[i].flag & Optflag_Reverse) 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 */ @@ -88,57 +88,62 @@ 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"), -#ifdef HAVE_SCROLLBARS - 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"), -#endif - BOOL (Rs_scrollTtyOutput, "scrollTtyOutput", NULL, Opt_scrollTtyOutput, NULL), - BOOL (Rs_scrollTtyOutput, NULL, "si", Opt_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"), -#ifdef TRANSPARENT - BOOL (Rs_transparent, "inheritPixmap", "ip", Opt_transparent, "inherit parent pixmap"), - BOOL (Rs_transparent_all, "inheritPixmapforce", "ipf", Opt_transparent_all, "forcefully inherit root pixmap"), - SWCH ("tr", Opt_transparent, NULL), -#if TINTING + SWCH ("C", Opt_console, 0, "intercept console messages"), + SWCH ("iconic", Opt_iconic, 0, "start iconic"), + SWCH ("ic", Opt_iconic, 0, NULL), /* short form */ + STRG (Rs_chdir, "chdir", "cd", "string", "start shell in this directory"), + 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_skipScroll, "skipScroll", "ss", Opt_skipScroll, 0, "skip scrolling"), + BOOL (Rs_pastableTabs, "pastableTabs", "ptab", Opt_pastableTabs, 0, "tab characters are pastable"), + RSTRG (Rs_scrollstyle, "scrollstyle", "mode"), + 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"), + 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 ENABLE_TRANSPARENCY + BOOL (Rs_transparent, "inheritPixmap", "ip", Opt_transparent, 0, "inherit parent pixmap"), + BOOL (Rs_transparent, "transparent", "tr", Opt_transparent, 0, "inherit parent pixmap"), STRG (Rs_color + Color_tint, "tintColor", "tint", "color", "tint color"), + STRG (Rs_shade, "shading", "sh", "number", "shade background by number %."), + STRG (Rs_blurradius, "blurRadius", "blr", "HxV", "gaussian blur radii to apply to the root background"), #endif +#if OFF_FOCUS_FADING + STRG (Rs_fade, "fading", "fade", "number", "fade colors by number % when losing focus"), + STRG (Rs_color + Color_fade, "fadeColor", "fadecolor", "color", "target color for off-focus fading"), #endif -#ifdef OFF_FOCUS_FADING - STRG (Rs_fade, "fading", "fade", "%", "make colors x% darker when urxvt is losing focus."), -#endif -#ifdef 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"), +# if ENABLE_FRILLS + BOOL (Rs_urgentOnBell, "urgentOnBell", NULL, Opt_urgentOnBell, 0, NULL), +# endif + 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 -#ifndef NO_FRILLS - BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, "triple click word selection"), - BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, "enable possibly insecure escape sequences"), +#if ENABLE_FRILLS + 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 -#ifdef CURSOR_BLINK - BOOL (Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"), +#if CURSOR_BLINK + 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"), @@ -150,7 +155,6 @@ RSTRG (Rs_color + minCOLOR + 5, "color5", "color"), RSTRG (Rs_color + minCOLOR + 6, "color6", "color"), RSTRG (Rs_color + minCOLOR + 7, "color7", "color"), -#ifndef NO_BRIGHTCOLOR RSTRG (Rs_color + minBrightCOLOR + 0, "color8", "color"), RSTRG (Rs_color + minBrightCOLOR + 1, "color9", "color"), RSTRG (Rs_color + minBrightCOLOR + 2, "color10", "color"), @@ -159,62 +163,80 @@ RSTRG (Rs_color + minBrightCOLOR + 5, "color13", "color"), RSTRG (Rs_color + minBrightCOLOR + 6, "color14", "color"), RSTRG (Rs_color + minBrightCOLOR + 7, "color15", "color"), -#endif /* NO_BRIGHTCOLOR */ #ifndef NO_BOLD_UNDERLINE_REVERSE - BOOL (Rs_realBold, "realBold", "rb", Opt_realBold, "use bold fonts for bold text"), RSTRG (Rs_color + Color_BD, "colorBD", "color"), + RSTRG (Rs_color + Color_IT, "colorIT", "color"), RSTRG (Rs_color + Color_UL, "colorUL", "color"), RSTRG (Rs_color + Color_RV, "colorRV", "color"), -#endif /* ! NO_BOLD_UNDERLINE_REVERSE */ -#ifdef KEEP_SCROLLCOLOR +#endif /* ! NO_BOLD_UNDERLINE_REVERSE */ +#if ENABLE_FRILLS + RSTRG (Rs_color + Color_underline, "underlineColor", "color"), +#endif RSTRG (Rs_color + Color_scroll, "scrollColor", "color"), +#ifdef RXVT_SCROLLBAR RSTRG (Rs_color + Color_trough, "troughColor", "color"), -#endif /* KEEP_SCROLLCOLOR */ +#endif #ifdef OPTION_HC STRG (Rs_color + Color_HC, "highlightColor", "hc", "color", "highlight color"), + RSTRG (Rs_color + Color_HTC, "highlightTextColor", "color"), #endif -#if defined (XPM_BACKGROUND) || (MENUBAR_MAX) +#ifndef NO_CURSORCOLOR + STRG (Rs_color + Color_cursor, "cursorColor", "cr", "color", "cursor color"), + /* command-line option = resource name */ + RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"), +#endif /* NO_CURSORCOLOR */ + 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 RSTRG (Rs_path, "path", "search path"), -#endif /* defined (XPM_BACKGROUND) || (MENUBAR_MAX) */ -#ifdef XPM_BACKGROUND STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"), -#endif /* XPM_BACKGROUND */ -#if (MENUBAR_MAX) - RSTRG (Rs_menu, "menu", "name[;tag]"), +# if ENABLE_EWMH + STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), +# endif #endif - STRG (Rs_font, "font", "fn", "fontname", "normal text font"), /* fonts: command-line option = resource name */ + STRG (Rs_font, "font", "fn", "fontname", "normal text font"), +#if ENABLE_STYLES + 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, 0, "font styles imply intensity changes"), +#endif #ifdef USE_XIM STRG (Rs_inputMethod, "inputMethod", "im", "name", "name of input method"), STRG (Rs_preeditType, "preeditType", "pt", "style", "input style: style = OverTheSpot|OffTheSpot|Root"), -#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) STRG (Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"), -#endif -#endif /* USE_XIM */ + STRG (Rs_imFont, "imFont", "imfont", "fontname", "fontset for styles OverTheSpot and OffTheSpot"), +#endif /* USE_XIM */ STRG (Rs_name, NULL, "name", "string", "client instance, icon, and title strings"), STRG (Rs_title, "title", "title", "string", "title name for window"), STRG (Rs_title, NULL, "T", NULL, NULL), /* short form */ STRG (Rs_iconName, "iconName", "n", "string", "icon name for window"), -#ifndef NO_CURSORCOLOR - STRG (Rs_color + Color_cursor, "cursorColor", "cr", "color", "cursor color"), - /* command-line option = resource name */ - RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"), -#endif /* NO_CURSORCOLOR */ - 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"), STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"), -#ifndef NO_FRILLS +#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"), + BOOL (Rs_buffered, "buffered", NULL, Opt_buffered, 0, NULL), +#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, 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"), -#endif -#ifndef NO_LINESPACE + BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, 0, "borderless window"), STRG (Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows"), + STRG (Rs_letterSpace, "letterSpace", "letsp", "number", "letter spacing adjustment"), +#endif +#ifdef BUILTIN_GLYPHS + BOOL (Rs_skipBuiltinGlyphs, "skipBuiltinGlyphs", "sbg", Opt_skipBuiltinGlyphs, 0, "do not use internal glyphs"), #endif - STRG (Rs_scrollBar_thickness, "thickness", "sbt", "number", "scrollbar thickness/width in pixels"), #ifdef POINTER_BLANK RSTRG (Rs_pointerBlankDelay, "pointerBlankDelay", "number"), #endif @@ -224,23 +246,28 @@ #ifndef NO_DELETE_KEY RSTRG (Rs_delete_key, "deletekey", "string"), #endif - RSTRG (Rs_selectstyle, "selectstyle", "mode"), - RSTRG (Rs_scrollstyle, "scrollstyle", "mode"), -#ifdef HAVE_SCROLLBARS - RSTRG (Rs_scrollBar_align, "scrollBar_align", "mode"), -#endif #ifdef PRINTPIPE RSTRG (Rs_print_pipe, "print-pipe", "string"), #endif STRG (Rs_modifier, "modifier", "mod", "modifier", "meta modifier = alt|meta|hyper|super|mod1|...|mod5"), - INFO ("xrm", "string", "X resource"), -#ifdef CUTCHAR_RESOURCE RSTRG (Rs_cutchars, "cutchars", "string"), -#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 + RSTRG (Rs_perl_eval, "perl-eval", "perl-eval"), // "string", "code to be evaluated after all extensions have been loaded"),TODO + RSTRG (Rs_perl_ext_1, "perl-ext-common", "string"), //, "colon-separated list of perl extensions to enable"),TODO + STRG (Rs_perl_ext_2, "perl-ext", "pe", "string", "colon-separated list of perl extensions to enable for this instance"), +#endif +#if ISO_14755 + 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..."), #endif INFO ("e", "command arg ...", "command to execute") }; @@ -250,86 +277,114 @@ #undef RSTRG #undef SWCH #undef BOOL -/*}}} */ -static const char releasestring[] = "Rxvt v" VERSION " - released: " DATE "\n"; -static const char optionsstring[] = "Options: " -#if defined(XPM_BACKGROUND) - "XPM," +static const char releasestring[] = "rxvt-unicode (" RXVTNAME ") v" VERSION " - released: " DATE "\n"; +static const char optionsstring[] = "options: " +#if ENABLE_PERL + "perl," #endif -#if defined(TRANSPARENT) - "transparent," +#if XFT + "xft," #endif -#if defined(UTMP_SUPPORT) - "utmp," +#if ENABLE_STYLES + "styles," #endif -#if defined(MENUBAR) - "menubar," +#if ENABLE_COMBINING + "combining," #endif -#if !defined(NO_FRILLS) - "frills," +#if TEXT_BLINK + "blink," #endif -#if !defined(NO_LINESPACE) - "linespace," +#if ISO_14755 + "iso14755," #endif -#if defined(PREFER_24BIT) - "24bit," +#if UNICODE_3 + "unicode3," #endif -#if defined(USE_XIM) - "XIM," + "encodings=eu+vn" +#if ENCODING_JP + "+jp" #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 +#if ENCODING_JP_EXT + "+jp-ext" +#endif +#if ENCODING_KR + "+kr" +#endif +#if ENCODING_ZH + "+zh" +#endif +#if ENCODING_ZH_EXT + "+zh-ext" #endif "," +#if OFF_FOCUS_FADING + "fade," +#endif +#if defined(ENABLE_TRANSPARENCY) + "transparent," + "tint," +#endif +#if HAVE_AFTERIMAGE + "afterimage," +#endif +#if HAVE_PIXBUF + "pixbuf," +#endif +#if defined(USE_XIM) + "XIM," +#endif #if defined(NO_BACKSPACE_KEY) "no_backspace," #endif #if defined(NO_DELETE_KEY) "no_delete," #endif -#if !defined(NO_STRINGS) - "strings," +#if EIGHT_BIT_CONTROLS + "8bitctrls," +#endif +#if defined(ENABLE_FRILLS) + "frills," +#endif +#if defined(SELECTION_SCROLLING) + "selectionscrolling," +#endif +#if MOUSE_WHEEL + "wheel," #endif -#if defined(TTY_256COLOR) - "256colour," +#if MOUSE_SLIP_WHEELING + "slipwheel," +#endif +#if defined(SMART_RESIZE) + "smart-resize," +#endif +#if defined(CURSOR_BLINK) + "cursorBlink," +#endif +#if defined(POINTER_BLANK) + "pointerBlank," #endif #if defined(NO_RESOURCES) - "NoResources" -#else -# if defined(USE_XGETDEFAULT) - "XGetDefaults" -# else - ".Xdefaults" -# endif + "NoResources," +#endif + "scrollbars=plain" +#if defined(RXVT_SCROLLBAR) + "+rxvt" +#endif +#if defined(NEXT_SCROLLBAR) + "+NeXT" +#endif +#if defined(XTERM_SCROLLBAR) + "+xterm" #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 @@ -344,30 +399,25 @@ case 0: /* brief listing */ rxvt_log (" [-help] [--help]\n"); - for (col = 1, i = 0; i < optList_size (); i++) + for (col = 1, i = 0; i < ARRAY_LENGTH(optList); i++) if (optList[i].desc != NULL) { - int len = 0; + int len = 0; - if (!optList_isBool (i)) - { - len = optList_strlen (i); - if (len > 0) - len++; /* account for space */ - } -#ifdef DEBUG_STRICT + if (optList[i].arg) + len = strlen (optList[i].arg) + 1; assert (optList[i].opt != NULL); -#endif - len += 4 + STRLEN (optList[i].opt) + (optList_isBool (i) ? 2: 0); + len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2 : 0); col += len; if (col > 79) - { /* assume regular width */ + { + /* assume regular width */ rxvt_log ("\n"); col = 1 + len; } rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt); - if (optList_strlen (i)) + if (optList[i].arg) rxvt_log (" %s]", optList[i].arg); else rxvt_log ("]"); @@ -377,15 +427,13 @@ case 1: /* full command-line listing */ rxvt_log (" [options] [-e command args]\n\nwhere options include:\n"); - for (i = 0; i < optList_size (); i++) + for (i = 0; i < ARRAY_LENGTH(optList); i++) if (optList[i].desc != NULL) { -#ifdef DEBUG_STRICT assert (optList[i].opt != NULL); -#endif rxvt_log (" %s%s %-*s%s%s\n", (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, - (INDENT - STRLEN (optList[i].opt) + (INDENT - strlen (optList[i].opt) + (optList_isBool (i) ? 0 : 2)), (optList[i].arg ? optList[i].arg : ""), (optList_isBool (i) ? "turn on/off " : ""), @@ -398,11 +446,11 @@ rxvt_log (" [options] [-e command args]\n\n" "where resources (long-options) include:\n"); - for (i = 0; i < optList_size (); i++) + for (i = 0; i < ARRAY_LENGTH(optList); i++) if (optList[i].kw != NULL) rxvt_log (" %s: %*s%s\n", optList[i].kw, - (INDENT - STRLEN (optList[i].kw)), "", /* XXX */ + (INDENT - strlen (optList[i].kw)), "", /* XXX */ (optList_isBool (i) ? "boolean" : optList[i].arg)); #ifdef KEYSYM_RESOURCE rxvt_log (" " "keysym.sym" ": %*s%s\n", @@ -415,7 +463,6 @@ rxvt_log ("\n\n"); rxvt_exit_failure (); - /* NOTREACHED */ } /*}}} */ @@ -424,27 +471,27 @@ 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++) { - unsigned int entry, longopt = 0; - const char *flag, *opt; + unsigned int entry, longopt = 0; + const char *opt; + int flag; opt = argv[i]; -#ifdef DEBUG_RESOURCES - fprintf (stderr, "argv[%d] = %s: ", i, opt); -#endif + if (*opt == '-') { - flag = On; + flag = 1; + if (*++opt == '-') longopt = *opt++; /* long option */ } else if (*opt == '+') { - flag = Off; + flag = 0; + if (*++opt == '+') longopt = *opt++; /* long option */ } @@ -455,66 +502,72 @@ continue; } - if (!STRCMP (opt, "help")) + if (!strcmp (opt, "help")) rxvt_usage (longopt ? 2 : 1); - if (!STRCMP (opt, "h")) + + if (!strcmp (opt, "h")) rxvt_usage (0); /* feature: always try to match long-options */ - for (entry = 0; entry < optList_size (); entry++) - if ((optList[entry].kw && !STRCMP (opt, optList[entry].kw)) + for (entry = 0; entry < ARRAY_LENGTH(optList); entry++) + if ((optList[entry].kw && !strcmp (opt, optList[entry].kw)) || (!longopt - && optList[entry].opt && !STRCMP (opt, optList[entry].opt))) + && optList[entry].opt && !strcmp (opt, optList[entry].opt))) break; - if (entry < optList_size ()) + if (entry < ARRAY_LENGTH(optList)) { if (optList_isReverse (entry)) - flag = flag == On ? Off : On; + flag = !flag; - if (optList_strlen (entry)) + if (optList_isString (entry)) { /* - * special cases are handled in main.c:main () to allow + * special cases are handled in init_resources () to allow * X resources to set these values before we settle for * default values */ if (optList[entry].doff != -1) - rs[optList[entry].doff] = flag == On && argv[i+1] - ? argv[++i] : 0; + { + if (flag && i+1 == argc) + rxvt_fatal ("option '%s' requires an argument, aborting.\n", argv [i]); + + rs[optList[entry].doff] = flag ? 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 - if (flag == On) - Options |= (optList[entry].flag); - else - Options &= ~ (optList[entry].flag); + { + /* boolean value */ + set_option (optList[entry].index, flag); if (optList[entry].doff != -1) - rs[optList[entry].doff] = flag; + rs[optList[entry].doff] = flag ? resval_on : resval_off; } } - else +#ifndef NO_RESOURCES + else if (!strcmp (opt, "xrm")) + { + if (i+1 < argc) + XrmPutLineResource (&option_db, argv[++i]); + } +#endif #ifdef KEYSYM_RESOURCE - /* if (!STRNCMP (opt, "keysym.", sizeof ("keysym.") - 1)) */ - if (rxvt_Str_match (opt, "keysym.")) - { - const char *str = argv[++i]; - - if (str != NULL) - parse_keysym (opt + sizeof ("keysym.") - 1, str); - } - else -#endif - { - bad_option = 1; - rxvt_warn ("\"%s\": unknown or malformed option.\n", opt); - } + else if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1)) + { + if (i+1 < argc) + { + char *res = rxvt_temp_buf (strlen (opt) + strlen (argv[++i]) + 6); + sprintf (res, "*.%s: %s\n", opt, argv[i]); + XrmPutLineResource (&option_db, res); + } + } +#endif + else + { + bad_option = 1; + rxvt_warn ("\"%s\": unknown or malformed option.\n", opt); + } } if (bad_option) @@ -533,19 +586,19 @@ * "rxvt" "keysym" "0xFF01" * value will be a string */ -/* 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; + int last; for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ ; + last--; GET_R->parse_keysym (XrmQuarkToString (quarks[last]), (char *)value->addr);//D//TODO return False; @@ -554,447 +607,203 @@ /* * look for something like this (XK_Delete) * rxvt*keysym.0xFFFF: "\177" - * - * arg will be - * NULL for ~/.Xdefaults and - * non-NULL for command-line options (need to allocate) */ -#define NEWARGLIM 500 /* `reasonable' size */ + +struct keysym_vocabulary_t +{ + const char *name; + unsigned short len; + unsigned short value; +}; +static const keysym_vocabulary_t keysym_vocabulary[] = +{ + { "ISOLevel3", 9, Level3Mask }, + { "AppKeypad", 9, AppKeypadMask }, + { "Control", 7, ControlMask }, + { "NumLock", 7, NumLockMask }, + { "Shift", 5, ShiftMask }, + { "Meta", 4, MetaMask }, + { "Lock", 4, LockMask }, + { "Mod1", 4, Mod1Mask }, + { "Mod2", 4, Mod2Mask }, + { "Mod3", 4, Mod3Mask }, + { "Mod4", 4, Mod4Mask }, + { "Mod5", 4, Mod5Mask }, + { "I", 1, Level3Mask }, + { "K", 1, AppKeypadMask }, + { "C", 1, ControlMask }, + { "N", 1, NumLockMask }, + { "S", 1, ShiftMask }, + { "M", 1, MetaMask }, + { "A", 1, MetaMask }, + { "L", 1, LockMask }, + { "1", 1, Mod1Mask }, + { "2", 1, Mod2Mask }, + { "3", 1, Mod3Mask }, + { "4", 1, Mod4Mask }, + { "5", 1, Mod5Mask }, +}; + int rxvt_term::parse_keysym (const char *str, const char *arg) { - int n, sym; - char *key_string, *newarg = NULL; - char newargstr[NEWARGLIM]; - - if (arg == NULL) - { - if ((n = rxvt_Str_match (str, "keysym.")) == 0) - return 0; - str += n; /* skip `keysym.' */ - } - /* some scanf () have trouble with a 0x prefix */ - if (isdigit (str[0])) - { - if (str[0] == '0' && toupper (str[1]) == 'X') - str += 2; - if (arg) - { - if (sscanf (str, (STRCHR (str, ':') ? "%x:" : "%x"), &sym) != 1) - return -1; - } - else - { - if (sscanf (str, "%x:", &sym) != 1) - return -1; + int sym; + unsigned int state = 0; + const char *key = strrchr (str, '-'); - /* cue to ':', it's there since sscanf () worked */ - STRNCPY (newargstr, STRCHR (str, ':') + 1, NEWARGLIM - 1); - newargstr[NEWARGLIM - 1] = '\0'; - newarg = newargstr; - } - } + if (!key) + key = str; else + key++; + + // string or key is empty + if (*arg == '\0' || *key == '\0') + return -1; + + // parse modifiers + while (str < key) { - /* - * convert keysym name to keysym number - */ - STRNCPY (newargstr, str, NEWARGLIM - 1); - newargstr[NEWARGLIM - 1] = '\0'; - if (arg == NULL) + unsigned int i; + + for (i=0; i < ARRAY_LENGTH(keysym_vocabulary); ++i) { - if ((newarg = STRCHR (newargstr, ':')) == NULL) - return -1; - *newarg++ = '\0'; /* terminate keysym name */ + if (strncmp (str, keysym_vocabulary [i].name, keysym_vocabulary [i].len) == 0) + { + state |= keysym_vocabulary[i].value; + str += keysym_vocabulary[i].len; + break; + } } - if ((sym = XStringToKeysym (newargstr)) == None) + + if (i >= ARRAY_LENGTH(keysym_vocabulary)) return -1; - } - if (sym < 0xFF00 || sym > 0xFFFF) /* we only do extended keys */ - return -1; - sym &= 0xFF; - if (Keysym_map[sym] != NULL) /* already set ? */ - return -1; + if (*str == '-') + ++str; + } - if (newarg == NULL) + // convert keysym name to keysym number + if ((sym = XStringToKeysym (str)) == None) { - STRNCPY (newargstr, arg, NEWARGLIM - 1); - newargstr[NEWARGLIM - 1] = '\0'; - newarg = newargstr; + // fallback on hexadecimal parsing + char *end; + sym = strtol (str, &end, 16); + if (*end) + return -1; } - rxvt_Str_trim (newarg); - if (*newarg == '\0' || (n = rxvt_Str_escaped (newarg)) == 0) - return -1; - MIN_IT (n, 255); - key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char)); - - key_string[0] = n; - STRNCPY (key_string + 1, newarg, n); - Keysym_map[sym] = (unsigned char *)key_string; + keyboard->register_user_translation (sym, state, arg); return 1; } -# endif /* KEYSYM_RESOURCE */ +# endif /* KEYSYM_RESOURCE */ +#endif /* NO_RESOURCES */ -# ifndef USE_XGETDEFAULT -/*{{{ rxvt_get_xdefaults () */ -/* - * the matching algorithm used for memory-save fake resources - */ -void -rxvt_term::get_xdefaults (FILE *stream, const char *name) +static char * +get_res (XrmDatabase database, const char *program, const char *option) { - unsigned int len; - char *str, buffer[256]; + char resource[512]; + char *type; + XrmValue result; - if (stream == NULL) - return; + snprintf (resource, sizeof (resource), "%s.%s", program, option); + XrmGetResource (database, resource, resource, &type, &result); - len = STRLEN (name); - while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) - { - unsigned int entry, n; + return result.addr; +} - while (*str && isspace (*str)) - str++; /* leading whitespace */ +const char * +rxvt_term::x_resource (const char *name) +{ + XrmDatabase database = XrmGetDatabase (dpy); - if ((str[len] != '*' && str[len] != '.') - || (len && STRNCMP (str, name, len))) - continue; - str += (len + 1); /* skip `name*' or `name.' */ + const char *p = get_res (database, rs[Rs_name], name); + const char *p0 = get_res (database, "!INVALIDPROGRAMMENAMEDONTMATCH!", name); -# ifdef KEYSYM_RESOURCE - if (!parse_keysym (str, NULL)) -# endif /* KEYSYM_RESOURCE */ - for (entry = 0; entry < optList_size (); entry++) - { - const char *kw = optList[entry].kw; - - if (kw == NULL) - continue; - - n = STRLEN (kw); - if (str[n] == ':' && rxvt_Str_match (str, kw)) - { - /* skip `keyword:' */ - str += n + 1; - rxvt_Str_trim (str); - n = STRLEN (str); - if (n && rs[optList[entry].doff] == NULL) - { - /* not already set */ - int s; - char *p = 0; - - for (int o = 0;;) - { - p = (char *)rxvt_realloc (p, o + n + 1); - MEMCPY (p + o, str, n); - o += n; - p[o] = 0; - - if (o == 0 || p[o - 1] != '\\') // continuation line - break; - - o--; // eat "\" - - if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL) - break; - - rxvt_Str_trim (str); - n = STRLEN (str); - } - - rs[optList[entry].doff] = p; - allocated.push_back (p); - - if (optList_isBool (entry)) - { - s = STRCASECMP (str, "TRUE") == 0 - || STRCASECMP (str, "YES") == 0 - || STRCASECMP (str, "ON") == 0 - || STRCASECMP (str, "1") == 0; - - if (optList_isReverse (entry)) - s = !s; - - if (s) - Options |= optList[entry].flag; - else - Options &= ~optList[entry].flag; - } - } - - break; - } - } + if (p == NULL || (p0 && strcmp (p, p0) == 0)) + { + p = get_res (database, RESCLASS, name); +#ifdef RESFALLBACK + if (p == NULL || (p0 && strcmp (p, p0) == 0)) + p = get_res (database, RESFALLBACK, name); +#endif } - rewind (stream); -} + if (p == NULL && p0) + p = p0; -/*}}} */ -# endif /* ! USE_XGETDEFAULT */ -#endif /* NO_RESOURCES */ + return p; +} -/*{{{ read the resources files */ -/* - * using XGetDefault () or the hand-rolled replacement - */ -/* ARGSUSED */ void -rxvt_term::extract_resources (Display *display __attribute__ ((unused)), const char *name) +rxvt_term::extract_resources () { #ifndef NO_RESOURCES - -# if defined XAPPLOADDIR -# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) - /* Compute the path of the possibly available localized Rxvt file */ - char *localepath = NULL; - - if (locale != NULL) - { /* XXX: must limit length of string */ - localepath = (char *)rxvt_malloc (256); - sprintf (localepath, XAPPLOADDIRLOCALE "/" RESCLASS, - (int) (258 - sizeof (XAPPLOADDIRLOCALE) - sizeof (RESCLASS)), - locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ - } - - { -# endif -# endif - -# ifdef USE_XGETDEFAULT - /* - * get resources using the X library function - */ - int entry; - -# ifdef XrmEnumOneLevel - int i; - char *displayResource, *xe; - XrmName name_prefix[3]; - XrmClass class_prefix[3]; - XrmDatabase database, rdb1; - char fname[1024]; - - XrmInitialize (); - database = NULL; - - /* Get any Xserver defaults */ - - displayResource = XResourceManagerString (display); - if (displayResource != NULL) - database = XrmGetStringDatabase (displayResource); - -# ifdef HAVE_EXTRA_XRESOURCE_FILES - /* Add in ~/.Xdefaults or ~/.Xresources */ + XrmDatabase database = XrmGetDatabase (dpy); + XrmMergeDatabases (option_db, &database); + option_db = NULL; + /* + * Query resources for options that affect us + */ + for (int entry = 0; entry < ARRAY_LENGTH(optList); entry++) { - char *ptr; + int s; + const char *kw = optList[entry].kw; - if ((ptr = (char *)getenv ("HOME")) == NULL) - ptr = "."; + if (kw == NULL || rs[optList[entry].doff] != NULL) + continue; // previously set - for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) + const char *p = x_resource (kw); + + if (p) { - sprintf (fname, "%-.*s/%s", sizeof (fname) - STRLEN (xnames[i]) - 2, - ptr, xnames[i]); - if ((rdb1 = XrmGetFileDatabase (fname))) + p = strdup (p); + allocated.push_back ((void *)p); + rs[optList[entry].doff] = p; + + if (optList_isBool (entry)) { - XrmMergeDatabases (rdb1, &database); -# ifndef HAVE_BOTH_XRESOURCE_FILES - break; -# endif + s = strcasecmp (p, "TRUE") == 0 + || strcasecmp (p, "YES") == 0 + || strcasecmp (p, "ON") == 0 + || strcasecmp (p, "1") == 0; + if (optList_isReverse (entry)) + s = !s; + + set_option (optList[entry].index, s); } } } -# endif - - /* Add in XENVIRONMENT file */ - if ((xe = (char *)getenv ("XENVIRONMENT")) != NULL - && (rdb1 = XrmGetFileDatabase (xe)) != NULL) - XrmMergeDatabases (rdb1, &database); - - /* Add in Rxvt file */ -# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) - if (localepath == NULL || (rdb1 = XrmGetFileDatabase (localepath)) == NULL) + /* + * [R5 or later]: enumerate the resource database + */ +# ifdef KEYSYM_RESOURCE + XrmName name_prefix[3]; + XrmClass class_prefix[3]; + + name_prefix[0] = XrmStringToName (rs[Rs_name]); + name_prefix[1] = XrmStringToName ("keysym"); + name_prefix[2] = NULLQUARK; + class_prefix[0] = XrmStringToName (RESCLASS); + class_prefix[1] = XrmStringToName ("Keysym"); + class_prefix[2] = NULLQUARK; + /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ + XrmEnumerateDatabase (database, name_prefix, class_prefix, + XrmEnumOneLevel, rxvt_define_key, NULL); +# ifdef RESFALLBACK + name_prefix[0] = XrmStringToName (RESFALLBACK); + name_prefix[1] = XrmStringToName ("keysym"); + class_prefix[0] = XrmStringToName (RESFALLBACK); + class_prefix[1] = XrmStringToName ("Keysym"); + /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ + XrmEnumerateDatabase (database, name_prefix, class_prefix, + XrmEnumOneLevel, rxvt_define_key, NULL); # endif - rdb1 = XrmGetFileDatabase (XAPPLOADDIR "/" RESCLASS); - - if (rdb1 != NULL) - XrmMergeDatabases (rdb1, &database); - - /* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */ - if ((xe = (char *)getenv ("XAPPLRESDIR")) != NULL) - { - sprintf (fname, "%-.*s/" RESCLASS, sizeof (fname) - - sizeof (RESCLASS) - 2, xe); - if ((rdb1 = XrmGetFileDatabase (fname)) != NULL) - XrmMergeDatabases (rdb1, &database); - } - - XrmSetDatabase (display, database); # endif - /* - * Query resources for options that affect us - */ - for (entry = 0; entry < optList_size (); entry++) - { - int s; - char *p, *p0; - const char *kw = optList[entry].kw; - - if (kw == NULL || rs[optList[entry].doff] != NULL) - continue; /* previously set */ - - p = XGetDefault (display, name, kw); - p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); - if (p == NULL || (p0 && STRCMP (p, p0) == 0)) - { - p = XGetDefault (display, RESCLASS, kw); -#ifdef RESFALLBACK - if (p == NULL || (p0 && STRCMP (p, p0) == 0)) - p = XGetDefault (display, RESFALLBACK, kw); -#endif - } - - if (p == NULL && p0) - p = p0; - - if (p) - { - rs[optList[entry].doff] = p; - - if (optList_isBool (entry)) - { - s = STRCASECMP (p, "TRUE") == 0 - || STRCASECMP (p, "YES") == 0 - || STRCASECMP (p, "ON") == 0 - || STRCASECMP (p, "1") == 0; - if (optList_isReverse (entry)) - s = !s; - if (s) - Options |= (optList[entry].flag); - else - Options &= ~ (optList[entry].flag); - } - } - } - - /* - * [R5 or later]: enumerate the resource database - */ -# ifdef XrmEnumOneLevel -# ifdef KEYSYM_RESOURCE - name_prefix[0] = XrmStringToName (name); - name_prefix[1] = XrmStringToName ("keysym"); - name_prefix[2] = NULLQUARK; - class_prefix[0] = XrmStringToName (RESCLASS); - class_prefix[1] = XrmStringToName ("Keysym"); - class_prefix[2] = NULLQUARK; - /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ - XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix, - XrmEnumOneLevel, rxvt_define_key, NULL); -# ifdef RESFALLBACK - name_prefix[0] = XrmStringToName (RESFALLBACK); - name_prefix[1] = XrmStringToName ("keysym"); - class_prefix[0] = XrmStringToName (RESFALLBACK); - class_prefix[1] = XrmStringToName ("Keysym"); - /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ - XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix, - XrmEnumOneLevel, rxvt_define_key, NULL); -# endif -# endif -# endif - -# else /* USE_XGETDEFAULT */ - /* get resources the hard way, but save lots of memory */ - FILE *fd = NULL; - char *home; - - if ((home = getenv ("HOME")) != NULL) - { - unsigned int i, len = STRLEN (home) + 2; - char *f = NULL; - - for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) - { - f = (char *)rxvt_realloc (f, (len + STRLEN (xnames[i])) * sizeof (char)); - - sprintf (f, "%s/%s", home, xnames[i]); - - if ((fd = fopen (f, "r")) != NULL) - break; - } - free (f); - } - /* - * The normal order to match resources is the following: - * @ global resources (partial match, ~/.Xdefaults) - * @ application file resources (XAPPLOADDIR/Rxvt) - * @ class resources (~/.Xdefaults) - * @ private resources (~/.Xdefaults) - * - * However, for the hand-rolled resources, the matching algorithm - * checks if a resource string value has already been allocated - * and won't overwrite it with (in this case) a less specific - * resource value. - * - * This avoids multiple allocation. Also, when we've called this - * routine command-line string options have already been applied so we - * needn't to allocate for those resources. - * - * So, search in resources from most to least specific. - * - * Also, use a special sub-class so that we can use either or both of - * "XTerm" and "Rxvt" as class names. - */ - - get_xdefaults (fd, name); - get_xdefaults (fd, RESCLASS); -# ifdef RESFALLBACK - get_xdefaults (fd, RESFALLBACK); -# endif - -# if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR) - { - FILE *ad = NULL; - -# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) - if (localepath == NULL || (ad = fopen (localepath, "r")) == NULL) -# endif - ad = fopen (XAPPLOADDIR "/" RESCLASS, "r"); - if (ad != NULL) - { - get_xdefaults (ad, RESCLASS); - get_xdefaults (ad, ""); - fclose (ad); - } - } -# endif /* XAPPLOADDIR */ - - get_xdefaults (fd, ""); /* partial match */ - if (fd != NULL) - fclose (fd); -# endif /* USE_XGETDEFAULT */ - -# if defined XAPPLOADDIR -# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) - - } - - /* Free the path of the possibly available localized Rxvt file */ - free (localepath); -# endif -# endif - -#endif /* NO_RESOURCES */ +#endif /* NO_RESOURCES */ } -/*}}} */ /*----------------------- end-of-file (C source) -----------------------*/