ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/xdefaults.C
(Generate patch)

Comparing rxvt-unicode/src/xdefaults.C (file contents):
Revision 1.13 by pcg, Tue Feb 24 21:41:16 2004 UTC vs.
Revision 1.43 by root, Wed Dec 15 00:53:23 2004 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: xdefaults.c 2 * File: xdefaults.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: xdefaults.C,v 1.13 2004/02/24 21:41:16 pcg Exp $
5 * 4 *
6 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
7 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> 6 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
8 * - original version 7 * - original version
9 * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca> 8 * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca>
9 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com>
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version. 14 * (at your option) any later version.
28 *----------------------------------------------------------------------*/ 28 *----------------------------------------------------------------------*/
29 29
30#include "../config.h" /* NECESSARY */ 30#include "../config.h" /* NECESSARY */
31#include "rxvt.h" /* NECESSARY */ 31#include "rxvt.h" /* NECESSARY */
32#include "version.h" 32#include "version.h"
33#include "xdefaults.intpro" /* PROTOS for internal routines */
34 33
35/* #define DEBUG_RESOURCES */ 34/* #define DEBUG_RESOURCES */
36 35
37static const char *const xnames[2] = { ".Xdefaults", ".Xresources" }; 36static const char *const xnames[2] = { ".Xdefaults", ".Xresources" };
38 37
63#define SWCH(opt, flag, desc) \ 62#define SWCH(opt, flag, desc) \
64 { (flag), -1, NULL, (opt), NULL, (desc)} 63 { (flag), -1, NULL, (opt), NULL, (desc)}
65 64
66/* convenient macros */ 65/* convenient macros */
67#define optList_strlen(i) \ 66#define optList_strlen(i) \
68 (optList[i].flag ? 0 : (optList[i].arg ? STRLEN (optList[i].arg) : 1)) 67 (optList[i].flag ? 0 : (optList[i].arg ? strlen (optList[i].arg) : 1))
69#define optList_isBool(i) \ 68#define optList_isBool(i) \
70 (optList[i].flag & Opt_Boolean) 69 (optList[i].flag & Opt_Boolean)
71#define optList_isReverse(i) \ 70#define optList_isReverse(i) \
72 (optList[i].flag & Opt_Reverse) 71 (optList[i].flag & Opt_Reverse)
73#define optList_size() \ 72#define optList_size() \
83 const char *desc; /* description */ 82 const char *desc; /* description */
84 } 83 }
85optList[] = { 84optList[] = {
86 STRG (Rs_display_name, NULL, "d", NULL, NULL), /* short form */ 85 STRG (Rs_display_name, NULL, "d", NULL, NULL), /* short form */
87 STRG (Rs_display_name, NULL, "display", "string", "X server to contact"), 86 STRG (Rs_display_name, NULL, "display", "string", "X server to contact"),
88 STRG (Rs_term_name, "termName", "tn", "string", 87 STRG (Rs_term_name, "termName", "tn", "string", "value of the TERM environment variable"),
89 "value of the TERM environment variable"),
90 STRG (Rs_geometry, NULL, "g", NULL, NULL), /* short form */ 88 STRG (Rs_geometry, NULL, "g", NULL, NULL), /* short form */
91 STRG (Rs_geometry, "geometry", "geometry", "geometry", 89 STRG (Rs_geometry, "geometry", "geometry", "geometry", "size (in characters) and position"),
92 "size (in characters) and position"),
93 SWCH ("C", Opt_console, "intercept console messages"), 90 SWCH ("C", Opt_console, "intercept console messages"),
94 SWCH ("iconic", Opt_iconic, "start iconic"), 91 SWCH ("iconic", Opt_iconic, "start iconic"),
95 SWCH ("ic", Opt_iconic, NULL), /* short form */ 92 SWCH ("ic", Opt_iconic, NULL), /* short form */
96 BOOL (Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo, 93 BOOL (Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo, "reverse video"),
97 "reverse video"),
98 BOOL (Rs_loginShell, "loginShell", "ls", Opt_loginShell, "login shell"), 94 BOOL (Rs_loginShell, "loginShell", "ls", Opt_loginShell, "login shell"),
99 BOOL (Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, "jump scrolling"), 95 BOOL (Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, "jump scrolling"),
96 BOOL (Rs_pastableTabs, "pastableTabs", "ptab", Opt_pastableTabs, "tab characters are pastable"),
100#ifdef HAVE_SCROLLBARS 97#ifdef HAVE_SCROLLBARS
101 BOOL (Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, "scrollbar"), 98 BOOL (Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, "scrollbar"),
102 BOOL (Rs_scrollBar_right, "scrollBar_right", "sr", Opt_scrollBar_right, 99 BOOL (Rs_scrollBar_right, "scrollBar_right", "sr", Opt_scrollBar_right, "scrollbar right"),
103 "scrollbar right"), 100 BOOL (Rs_scrollBar_floating, "scrollBar_floating", "st", Opt_scrollBar_floating, "scrollbar without a trough"),
104 BOOL (Rs_scrollBar_floating, "scrollBar_floating", "st",
105 Opt_scrollBar_floating, "scrollbar without a trough"),
106#endif 101#endif
107 BOOL (Rs_scrollTtyOutput, "scrollTtyOutput", NULL, Opt_scrollTtyOutput, 102 BOOL (Rs_scrollTtyOutput, "scrollTtyOutput", NULL, Opt_scrollTtyOutput, NULL),
108 NULL),
109 BOOL (Rs_scrollTtyOutput, NULL, "si", Opt_Reverse | Opt_scrollTtyOutput, 103 BOOL (Rs_scrollTtyOutput, NULL, "si", Opt_Reverse | Opt_scrollTtyOutput, "scroll-on-tty-output inhibit"),
110 "scroll-on-tty-output inhibit"),
111 BOOL (Rs_scrollTtyKeypress, "scrollTtyKeypress", "sk", Opt_scrollTtyKeypress, 104 BOOL (Rs_scrollTtyKeypress, "scrollTtyKeypress", "sk", Opt_scrollTtyKeypress, "scroll-on-keypress"),
112 "scroll-on-keypress"),
113 BOOL (Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer, 105 BOOL (Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer, "scroll-with-buffer"),
114 "scroll-with-buffer"),
115#ifdef TRANSPARENT 106#ifdef TRANSPARENT
116 BOOL (Rs_transparent, "inheritPixmap", "ip", Opt_transparent, 107 BOOL (Rs_transparent, "inheritPixmap", "ip", Opt_transparent, "inherit parent pixmap"),
117 "inherit parent pixmap"),
118 BOOL (Rs_transparent_all, "inheritPixmapforce", "ipf", Opt_transparent_all, 108 BOOL (Rs_transparent_all, "inheritPixmapforce", "ipf", Opt_transparent_all, "forcefully inherit root pixmap"),
119 "forcefully inherit root pixmap"),
120 SWCH ("tr", Opt_transparent, NULL), 109 SWCH ("tr", Opt_transparent, NULL),
110#if TINTING
111 STRG (Rs_color + Color_tint, "tintColor", "tint", "color", "tint color"),
112#endif
113#endif
114#ifdef OFF_FOCUS_FADING
115 STRG (Rs_fade, "fading", "fade", "%", "make colors x% darker when rxvt-unicode is losing focus."),
116#endif
117#ifdef TINTING
118 STRG (Rs_shade, "shading", "sh", "%", "shade background by x% when tinting."),
121#endif 119#endif
122 BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, "utmp inhibit"), 120 BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, "utmp inhibit"),
123#ifndef NO_BELL 121#ifndef NO_BELL
124 BOOL (Rs_visualBell, "visualBell", "vb", Opt_visualBell, "visual bell"), 122 BOOL (Rs_visualBell, "visualBell", "vb", Opt_visualBell, "visual bell"),
125# if ! defined(NO_MAPALERT) && defined(MAPALERT_OPTION) 123# if ! defined(NO_MAPALERT) && defined(MAPALERT_OPTION)
128#endif 126#endif
129#ifdef META8_OPTION 127#ifdef META8_OPTION
130 BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, NULL), 128 BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, NULL),
131#endif 129#endif
132#ifdef MOUSE_WHEEL 130#ifdef MOUSE_WHEEL
133 BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, 131 BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, NULL),
134 NULL),
135#endif 132#endif
136#ifdef MULTICHAR_SET 133#if ENABLE_FRILLS
137 BOOL (Rs_mc_hack, "multibyte_cursor", "mcc", Opt_mc_hack,
138 "Multibyte character cursor movement"),
139#endif
140#ifndef NO_FRILLS
141 BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, 134 BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, "triple click word selection"),
142 "triple click word selection"), 135 BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, "enable possibly insecure escape sequences"),
143#endif 136#endif
144#ifdef CURSOR_BLINK 137#ifdef CURSOR_BLINK
145 BOOL (Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"), 138 BOOL (Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"),
146#endif 139#endif
147#ifdef POINTER_BLANK 140#ifdef POINTER_BLANK
167 RSTRG (Rs_color + minBrightCOLOR + 6, "color14", "color"), 160 RSTRG (Rs_color + minBrightCOLOR + 6, "color14", "color"),
168 RSTRG (Rs_color + minBrightCOLOR + 7, "color15", "color"), 161 RSTRG (Rs_color + minBrightCOLOR + 7, "color15", "color"),
169#endif /* NO_BRIGHTCOLOR */ 162#endif /* NO_BRIGHTCOLOR */
170#ifndef NO_BOLD_UNDERLINE_REVERSE 163#ifndef NO_BOLD_UNDERLINE_REVERSE
171 RSTRG (Rs_color + Color_BD, "colorBD", "color"), 164 RSTRG (Rs_color + Color_BD, "colorBD", "color"),
165 RSTRG (Rs_color + Color_IT, "colorIT", "color"),
172 RSTRG (Rs_color + Color_UL, "colorUL", "color"), 166 RSTRG (Rs_color + Color_UL, "colorUL", "color"),
173 RSTRG (Rs_color + Color_RV, "colorRV", "color"), 167 RSTRG (Rs_color + Color_RV, "colorRV", "color"),
174#endif /* ! NO_BOLD_UNDERLINE_REVERSE */ 168#endif /* ! NO_BOLD_UNDERLINE_REVERSE */
169#if ENABLE_FRILLS
170 RSTRG (Rs_color + Color_underline, "underlineColor", "color"),
171#endif
175#ifdef KEEP_SCROLLCOLOR 172#ifdef KEEP_SCROLLCOLOR
176 RSTRG (Rs_color + Color_scroll, "scrollColor", "color"), 173 RSTRG (Rs_color + Color_scroll, "scrollColor", "color"),
177 RSTRG (Rs_color + Color_trough, "troughColor", "color"), 174 RSTRG (Rs_color + Color_trough, "troughColor", "color"),
178#endif /* KEEP_SCROLLCOLOR */ 175#endif /* KEEP_SCROLLCOLOR */
179#ifdef OPTION_HC 176#ifdef OPTION_HC
181#endif 178#endif
182#if defined (XPM_BACKGROUND) || (MENUBAR_MAX) 179#if defined (XPM_BACKGROUND) || (MENUBAR_MAX)
183 RSTRG (Rs_path, "path", "search path"), 180 RSTRG (Rs_path, "path", "search path"),
184#endif /* defined (XPM_BACKGROUND) || (MENUBAR_MAX) */ 181#endif /* defined (XPM_BACKGROUND) || (MENUBAR_MAX) */
185#ifdef XPM_BACKGROUND 182#ifdef XPM_BACKGROUND
186 STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", 183 STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"),
187 "background pixmap"),
188#endif /* XPM_BACKGROUND */ 184#endif /* XPM_BACKGROUND */
189#if (MENUBAR_MAX) 185#if (MENUBAR_MAX)
190 RSTRG (Rs_menu, "menu", "name[;tag]"), 186 RSTRG (Rs_menu, "menu", "name[;tag]"),
191#endif 187#endif
188 /* fonts: command-line option = resource name */
192 STRG (Rs_font, "font", "fn", "fontname", "normal text font"), 189 STRG (Rs_font, "font", "fn", "fontname", "normal text font"),
193 /* fonts: command-line option = resource name */ 190#if ENABLE_STYLES
191 STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"),
192 STRG (Rs_italicFont, "italicFont", "fi", "fontname", "italic font"),
193 STRG (Rs_boldItalicFont, "boldItalicFont", "fbi", "fontname", "bold italic font"),
194#endif
194#ifdef USE_XIM 195#ifdef USE_XIM
195 STRG (Rs_inputMethod, "inputMethod", "im", "name", "name of input method"), 196 STRG (Rs_inputMethod, "inputMethod", "im", "name", "name of input method"),
196 STRG (Rs_preeditType, "preeditType", "pt", "style", 197 STRG (Rs_preeditType, "preeditType", "pt", "style", "input style: style = OverTheSpot|OffTheSpot|Root"),
197 "input style: style = OverTheSpot|OffTheSpot|Root"),
198#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) 198#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
199 STRG (Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"), 199 STRG (Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"),
200#endif 200#endif
201#endif /* USE_XIM */ 201#endif /* USE_XIM */
202 STRG (Rs_name, NULL, "name", "string", 202 STRG (Rs_name, NULL, "name", "string", "client instance, icon, and title strings"),
203 "client instance, icon, and title strings"),
204 STRG (Rs_title, "title", "title", "string", "title name for window"), 203 STRG (Rs_title, "title", "title", "string", "title name for window"),
205 STRG (Rs_title, NULL, "T", NULL, NULL), /* short form */ 204 STRG (Rs_title, NULL, "T", NULL, NULL), /* short form */
206 STRG (Rs_iconName, "iconName", "n", "string", "icon name for window"), 205 STRG (Rs_iconName, "iconName", "n", "string", "icon name for window"),
207#ifndef NO_CURSORCOLOR 206#ifndef NO_CURSORCOLOR
208 STRG (Rs_color + Color_cursor, "cursorColor", "cr", "color", "cursor color"), 207 STRG (Rs_color + Color_cursor, "cursorColor", "cr", "color", "cursor color"),
209 /* command-line option = resource name */ 208 /* command-line option = resource name */
210 RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"), 209 RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"),
211#endif /* NO_CURSORCOLOR */ 210#endif /* NO_CURSORCOLOR */
212 STRG (Rs_color + Color_pointer, "pointerColor", "pr", "color", 211 STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"),
213 "pointer color"), 212 STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"),
214 STRG (Rs_color + Color_border, "borderColor", "bd", "color", 213 STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"),
215 "border color"),
216 STRG (Rs_saveLines, "saveLines", "sl", "number", 214 STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"),
217 "number of scrolled lines to save"), 215#if ENABLE_FRILLS
218#ifndef NO_FRILLS
219 STRG (Rs_ext_bwidth, "externalBorder", "w", "number", 216 STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"),
220 "external border in pixels"),
221 STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL), 217 STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL),
222 STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), 218 STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL),
223 STRG (Rs_int_bwidth, "internalBorder", "b", "number", 219 STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"),
224 "internal border in pixels"), 220 BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, "borderless window"),
225#endif 221#endif
226#ifndef NO_LINESPACE 222#ifndef NO_LINESPACE
227 STRG (Rs_lineSpace, "lineSpace", "lsp", "number", 223 STRG (Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows"),
228 "number of extra pixels between rows"),
229#endif 224#endif
230 STRG (Rs_scrollBar_thickness, "thickness", "sbt", "number", 225 STRG (Rs_scrollBar_thickness, "thickness", "sbt", "number", "scrollbar thickness/width in pixels"),
231 "scrollbar thickness/width in pixels"),
232#ifdef POINTER_BLANK 226#ifdef POINTER_BLANK
233 RSTRG (Rs_pointerBlankDelay, "pointerBlankDelay", "number"), 227 RSTRG (Rs_pointerBlankDelay, "pointerBlankDelay", "number"),
234#endif 228#endif
235#ifndef NO_BACKSPACE_KEY 229#ifndef NO_BACKSPACE_KEY
236 RSTRG (Rs_backspace_key, "backspacekey", "string"), 230 RSTRG (Rs_backspace_key, "backspacekey", "string"),
244 RSTRG (Rs_scrollBar_align, "scrollBar_align", "mode"), 238 RSTRG (Rs_scrollBar_align, "scrollBar_align", "mode"),
245#endif 239#endif
246#ifdef PRINTPIPE 240#ifdef PRINTPIPE
247 RSTRG (Rs_print_pipe, "print-pipe", "string"), 241 RSTRG (Rs_print_pipe, "print-pipe", "string"),
248#endif 242#endif
249#if defined (HOTKEY_CTRL) || defined (HOTKEY_META) 243 STRG (Rs_modifier, "modifier", "mod", "modifier", "meta modifier = alt|meta|hyper|super|mod1|...|mod5"),
250 RSTRG (Rs_bigfont_key, "bigfont_key", "keysym"),
251 RSTRG (Rs_smallfont_key, "smallfont_key", "keysym"),
252#endif
253 STRG (Rs_modifier, "modifier", "mod", "modifier",
254 "meta modifier = alt|meta|hyper|super|mod1|...|mod5"),
255 INFO ("xrm", "string", "X resource"), 244 INFO ("xrm", "string", "X resource"),
256#ifdef CUTCHAR_RESOURCE 245#ifdef CUTCHAR_RESOURCE
257 RSTRG (Rs_cutchars, "cutchars", "string"), 246 RSTRG (Rs_cutchars, "cutchars", "string"),
258#endif /* CUTCHAR_RESOURCE */ 247#endif /* CUTCHAR_RESOURCE */
259#ifdef ACS_ASCII
260 RSTRG (Rs_acs_chars, "acsChars", "string"),
261#endif /* ACS_ASCII */
262 RSTRG (Rs_answerbackstring, "answerbackString", "string"), 248 RSTRG (Rs_answerbackstring, "answerbackString", "string"),
249#ifndef NO_SECONDARY_SCREEN
250 BOOL (Rs_secondaryScreen, "secondaryScreen", "ssc", Opt_secondaryScreen, "enable secondary screen"),
251 BOOL (Rs_secondaryScroll, "secondaryScroll", "ssr", Opt_secondaryScroll, "enable secondary screen scroll"),
252#endif
263 INFO ("e", "command arg ...", "command to execute") 253 INFO ("e", "command arg ...", "command to execute")
264 }; 254 };
265 255
266#undef INFO 256#undef INFO
267#undef STRG 257#undef STRG
268#undef RSTRG 258#undef RSTRG
269#undef SWCH 259#undef SWCH
270#undef BOOL 260#undef BOOL
271/*}}} */ 261/*}}} */
272 262
273static const char releasestring[] = "Rxvt v" VERSION " - released: " DATE "\n"; 263static const char releasestring[] = "rxvt-unicode (" RXVTNAME ") v" VERSION " - released: " DATE "\n";
274static const char optionsstring[] = "Options: " 264static const char optionsstring[] = "options: "
265#if XFT
266 "xft,"
267#endif
268#if ENABLE_STYLES
269 "styles,"
270#endif
271#if ENABLE_COMBINING
272 "combining,"
273#endif
274#if TEXT_BLINK
275 "blink,"
276#endif
277#if ISO_14755
278 "iso14755,"
279#endif
280#if UNICODE_3
281 "unicode3,"
282#endif
283 "encodings=eu+vn"
284#if ENCODING_JP
285 "+jp"
286#endif
287#if ENCODING_JP_EXT
288 "+jp-ext"
289#endif
290#if ENCODING_KR
291 "+kr"
292#endif
293#if ENCODING_ZH
294 "+zh"
295#endif
296#if ENCODING_ZH_EXT
297 "+zh-ext"
298#endif
299 ","
300#if OFF_FOCUS_FADING
301 "fade,"
302#endif
275#if defined(XPM_BACKGROUND) 303#if defined(XPM_BACKGROUND)
276 "XPM," 304 "XPM,"
277#endif 305#endif
278#if defined(TRANSPARENT) 306#if defined(TRANSPARENT)
279 "transparent," 307 "transparent,"
280#endif 308#endif
309#if TINTING
310 "tint,"
311#endif
281#if defined(UTMP_SUPPORT) 312#if defined(UTMP_SUPPORT)
282 "utmp," 313 "utmp,"
283#endif 314#endif
284#if defined(MENUBAR) 315#if defined(MENUBAR)
285 "menubar," 316 "menubar,"
286#endif 317#endif
287#if !defined(NO_FRILLS)
288 "frills,"
289#endif
290#if !defined(NO_LINESPACE)
291 "linespace,"
292#endif
293#if defined(PREFER_24BIT)
294 "24bit,"
295#endif
296#if defined(USE_XIM) 318#if defined(USE_XIM)
297 "XIM," 319 "XIM,"
298#endif
299#if defined(MULTICHAR_SET)
300 "multichar_languages,"
301#endif 320#endif
302 "scrollbars=" 321 "scrollbars="
303#if !defined(HAVE_SCROLLBARS) 322#if !defined(HAVE_SCROLLBARS)
304 "NONE" 323 "NONE"
305#else 324#else
325# if defined(PLAIN_SCROLLBAR)
326 "plain"
327# if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR)
328 "+"
329# endif
330# endif
306# if defined(RXVT_SCROLLBAR) 331# if defined(RXVT_SCROLLBAR)
307 "rxvt" 332 "rxvt"
308# if defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) 333# if defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR)
309 "+" 334 "+"
310# endif 335# endif
324 "no_backspace," 349 "no_backspace,"
325#endif 350#endif
326#if defined(NO_DELETE_KEY) 351#if defined(NO_DELETE_KEY)
327 "no_delete," 352 "no_delete,"
328#endif 353#endif
354#if EIGHT_BIT_CONTROLS
355 "8bitctrls,"
356#endif
329#if !defined(NO_STRINGS) 357#if !defined(NO_STRINGS)
330 "strings," 358 "strings,"
331#endif 359#endif
332#if defined(TTY_256COLOR) 360#if defined(ENABLE_FRILLS)
361 "frills,"
362#endif
363#if !defined(NO_LINESPACE)
364 "linespace,"
365#endif
366#if defined(PREFER_24BIT)
333 "256colour," 367 "24bit,"
368#endif
369#if defined(SELECTION_SCROLLING)
370 "selectionscrolling,"
371#endif
372#if MOUSE_WHEEL
373 "wheel,"
374#endif
375#if MOUSE_SLIP_WHEELING
376 "slipwheel,"
377#endif
378#if defined(SMART_RESIZE)
379 "smart-resize,"
380#endif
381#if defined(CURSOR_BLINK)
382 "cursorBlink,"
383#endif
384#if defined(POINTER_BLANK)
385 "pointerBlank,"
334#endif 386#endif
335#if defined(NO_RESOURCES) 387#if defined(NO_RESOURCES)
336 "NoResources" 388 "NoResources"
337#else 389#else
338# if defined(USE_XGETDEFAULT) 390# if defined(USE_XGETDEFAULT)
348/*{{{ usage: */ 400/*{{{ usage: */
349/*----------------------------------------------------------------------*/ 401/*----------------------------------------------------------------------*/
350static void 402static void
351rxvt_usage (int type) 403rxvt_usage (int type)
352{ 404{
353 unsigned int i, col; 405 unsigned int i, col;
354 406
355 write (STDERR_FILENO, releasestring, sizeof (releasestring) - 1); 407 rxvt_log ("%s%s%s", releasestring, optionsstring, RESNAME);
356 write (STDERR_FILENO, optionsstring, sizeof (optionsstring) - 1);
357 write (STDERR_FILENO, APL_NAME, sizeof (APL_NAME) - 1);
358 408
359 switch (type) 409 switch (type)
360 { 410 {
361 case 0: /* brief listing */ 411 case 0: /* brief listing */
362 fprintf (stderr, " [-help] [--help]\n"); 412 rxvt_log (" [-help] [--help]\n");
413
363 for (col = 1, i = 0; i < optList_size (); i++) 414 for (col = 1, i = 0; i < optList_size (); i++)
364 if (optList[i].desc != NULL) 415 if (optList[i].desc != NULL)
365 { 416 {
366 int len = 0; 417 int len = 0;
367 418
372 len++; /* account for space */ 423 len++; /* account for space */
373 } 424 }
374#ifdef DEBUG_STRICT 425#ifdef DEBUG_STRICT
375 assert (optList[i].opt != NULL); 426 assert (optList[i].opt != NULL);
376#endif 427#endif
377 len += 4 + STRLEN (optList[i].opt) + (optList_isBool (i) ? 2: 0); 428 len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2: 0);
378 col += len; 429 col += len;
379 if (col > 79) 430 if (col > 79)
380 { /* assume regular width */ 431 { /* assume regular width */
381 putc ('\n', stderr); 432 rxvt_log ("\n");
382 col = 1 + len; 433 col = 1 + len;
383 } 434 }
435
384 fprintf (stderr, " [-%s%s", (optList_isBool (i) ? "/+" : ""), 436 rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt);
385 optList[i].opt);
386 if (optList_strlen (i)) 437 if (optList_strlen (i))
387 fprintf (stderr, " %s]", optList[i].arg); 438 rxvt_log (" %s]", optList[i].arg);
388 else 439 else
389 fprintf (stderr, "]"); 440 rxvt_log ("]");
390 } 441 }
391 break; 442 break;
392 443
393 case 1: /* full command-line listing */ 444 case 1: /* full command-line listing */
394 fprintf (stderr, " [options] [-e command args]\n\n" 445 rxvt_log (" [options] [-e command args]\n\nwhere options include:\n");
395 "where options include:\n"); 446
396 for (i = 0; i < optList_size (); i++) 447 for (i = 0; i < optList_size (); i++)
397 if (optList[i].desc != NULL) 448 if (optList[i].desc != NULL)
398 { 449 {
399#ifdef DEBUG_STRICT 450#ifdef DEBUG_STRICT
400 assert (optList[i].opt != NULL); 451 assert (optList[i].opt != NULL);
401#endif 452#endif
402 fprintf (stderr, " %s%s %-*s%s%s\n", 453 rxvt_log (" %s%s %-*s%s%s\n",
403 (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, 454 (optList_isBool (i) ? "-/+" : "-"), optList[i].opt,
404 (INDENT - STRLEN (optList[i].opt) 455 (INDENT - strlen (optList[i].opt)
405 + (optList_isBool (i) ? 0 : 2)), 456 + (optList_isBool (i) ? 0 : 2)),
406 (optList[i].arg ? optList[i].arg : ""), 457 (optList[i].arg ? optList[i].arg : ""),
407 (optList_isBool (i) ? "turn on/off " : ""), 458 (optList_isBool (i) ? "turn on/off " : ""),
408 optList[i].desc); 459 optList[i].desc);
409 } 460 }
410 fprintf (stderr, "\n --help to list long-options"); 461 rxvt_log ("\n --help to list long-options");
411 break; 462 break;
412 463
413 case 2: /* full resource listing */ 464 case 2: /* full resource listing */
414 fprintf (stderr,
415 " [options] [-e command args]\n\n" 465 rxvt_log (" [options] [-e command args]\n\n"
416 "where resources (long-options) include:\n"); 466 "where resources (long-options) include:\n");
417 467
418 for (i = 0; i < optList_size (); i++) 468 for (i = 0; i < optList_size (); i++)
419 if (optList[i].kw != NULL) 469 if (optList[i].kw != NULL)
420 fprintf (stderr, " %s: %*s%s\n", 470 rxvt_log (" %s: %*s%s\n",
421 optList[i].kw, 471 optList[i].kw,
422 (INDENT - STRLEN (optList[i].kw)), "", /* XXX */ 472 (INDENT - strlen (optList[i].kw)), "", /* XXX */
423 (optList_isBool (i) ? "boolean" : optList[i].arg)); 473 (optList_isBool (i) ? "boolean" : optList[i].arg));
424#ifdef KEYSYM_RESOURCE 474#ifdef KEYSYM_RESOURCE
425 fprintf (stderr, " " "keysym.sym" ": %*s%s\n", 475 rxvt_log (" " "keysym.sym" ": %*s%s\n",
426 (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */ 476 (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */
427 "keysym"); 477 "keysym");
428#endif 478#endif
429 fprintf (stderr, "\n -help to list options"); 479 rxvt_log ("\n -help to list options");
430 break; 480 break;
431 } 481 }
432 fprintf (stderr, "\n\n"); 482
433 exit (EXIT_FAILURE); 483 rxvt_log ("\n\n");
484 rxvt_exit_failure ();
434 /* NOTREACHED */ 485 /* NOTREACHED */
435} 486}
436 487
437/*}}} */ 488/*}}} */
438 489
465 longopt = *opt++; /* long option */ 516 longopt = *opt++; /* long option */
466 } 517 }
467 else 518 else
468 { 519 {
469 bad_option = 1; 520 bad_option = 1;
470 rxvt_print_error ("bad option \"%s\"", opt); 521 rxvt_warn ("\"%s\": malformed option.\n", opt);
471 continue; 522 continue;
472 } 523 }
473 524
474 if (!STRCMP (opt, "help")) 525 if (!strcmp (opt, "help"))
475 rxvt_usage (longopt ? 2 : 1); 526 rxvt_usage (longopt ? 2 : 1);
476 if (!STRCMP (opt, "h")) 527 if (!strcmp (opt, "h"))
477 rxvt_usage (0); 528 rxvt_usage (0);
478 529
479 /* feature: always try to match long-options */ 530 /* feature: always try to match long-options */
480 for (entry = 0; entry < optList_size (); entry++) 531 for (entry = 0; entry < optList_size (); entry++)
481 if ((optList[entry].kw && !STRCMP (opt, optList[entry].kw)) 532 if ((optList[entry].kw && !strcmp (opt, optList[entry].kw))
482 || (!longopt 533 || (!longopt
483 && optList[entry].opt && !STRCMP (opt, optList[entry].opt))) 534 && optList[entry].opt && !strcmp (opt, optList[entry].opt)))
484 break; 535 break;
485 536
486 if (entry < optList_size ()) 537 if (entry < optList_size ())
487 { 538 {
488 if (optList_isReverse (entry)) 539 if (optList_isReverse (entry))
489 flag = flag == On ? Off : On; 540 flag = flag == On ? Off : On;
541
490 if (optList_strlen (entry)) 542 if (optList_strlen (entry))
491 { /* string value */
492 const char *str = argv[++i];
493
494#ifdef DEBUG_RESOURCES
495 fprintf (stderr, "string (%s,%s) = ",
496 optList[entry].opt ? optList[entry].opt : "nil",
497 optList[entry].kw ? optList[entry].kw : "nil");
498#endif
499 if (flag == On && str && (optList[entry].doff != -1))
500 { 543 {
501#ifdef DEBUG_RESOURCES
502 fprintf (stderr, "\"%s\"\n", str);
503#endif
504 rs[optList[entry].doff] = str;
505 /* 544 /*
506 * special cases are handled in main.c:main () to allow 545 * special cases are handled in main.c:main () to allow
507 * X resources to set these values before we settle for 546 * X resources to set these values before we settle for
508 * default values 547 * default values
509 */ 548 */
510 }
511#ifdef DEBUG_RESOURCES
512 else
513 fprintf (stderr, "???\n");
514#endif
515 549
550 if (optList[entry].doff != -1)
551 rs[optList[entry].doff] = flag == On && argv[i+1]
552 ? argv[++i] : 0;
516 } 553 }
517 else 554 else
518 { /* boolean value */ 555 { /* boolean value */
519#ifdef DEBUG_RESOURCES 556#ifdef DEBUG_RESOURCES
520 fprintf (stderr, "boolean (%s,%s) = %s\n", 557 fprintf (stderr, "boolean (%s,%s) = %s\n",
521 optList[entry].opt, optList[entry].kw, flag); 558 optList[entry].opt, optList[entry].kw, flag);
522#endif 559#endif
523 if (flag == On) 560 if (flag == On)
524 Options |= (optList[entry].flag); 561 options |= (optList[entry].flag);
525 else 562 else
526 Options &= ~ (optList[entry].flag); 563 options &= ~ (optList[entry].flag);
527 564
528 if (optList[entry].doff != -1) 565 if (optList[entry].doff != -1)
529 rs[optList[entry].doff] = flag; 566 rs[optList[entry].doff] = flag;
530 } 567 }
531 } 568 }
532 else 569 else
533#ifdef KEYSYM_RESOURCE 570#ifdef KEYSYM_RESOURCE
534 /* if (!STRNCMP (opt, "keysym.", sizeof ("keysym.") - 1)) */ 571 /* if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1)) */
535 if (rxvt_Str_match (opt, "keysym.")) 572 if (rxvt_Str_match (opt, "keysym."))
536 { 573 {
537 const char *str = argv[++i]; 574 const char *str = argv[++i];
538 575
539 if (str != NULL) 576 if (str != NULL)
540 parse_keysym (opt + sizeof ("keysym.") - 1, str); 577 parse_keysym (opt + sizeof ("keysym.") - 1, str);
541 } 578 }
542 else 579 else
543#endif 580#endif
581 {
544 bad_option = 1; 582 bad_option = 1;
583 rxvt_warn ("\"%s\": unknown or malformed option.\n", opt);
584 }
545 } 585 }
546 586
547 if (bad_option) 587 if (bad_option)
548 rxvt_usage (0); 588 rxvt_usage (0);
549} 589}
605 { 645 {
606 if (str[0] == '0' && toupper (str[1]) == 'X') 646 if (str[0] == '0' && toupper (str[1]) == 'X')
607 str += 2; 647 str += 2;
608 if (arg) 648 if (arg)
609 { 649 {
610 if (sscanf (str, (STRCHR (str, ':') ? "%x:" : "%x"), &sym) != 1) 650 if (sscanf (str, (strchr (str, ':') ? "%x:" : "%x"), &sym) != 1)
611 return -1; 651 return -1;
612 } 652 }
613 else 653 else
614 { 654 {
615 if (sscanf (str, "%x:", &sym) != 1) 655 if (sscanf (str, "%x:", &sym) != 1)
616 return -1; 656 return -1;
617 657
618 /* cue to ':', it's there since sscanf () worked */ 658 /* cue to ':', it's there since sscanf () worked */
619 STRNCPY (newargstr, STRCHR (str, ':') + 1, NEWARGLIM - 1); 659 strncpy (newargstr, strchr (str, ':') + 1, NEWARGLIM - 1);
620 newargstr[NEWARGLIM - 1] = '\0'; 660 newargstr[NEWARGLIM - 1] = '\0';
621 newarg = newargstr; 661 newarg = newargstr;
622 } 662 }
623 } 663 }
624 else 664 else
625 { 665 {
626 /* 666 /*
627 * convert keysym name to keysym number 667 * convert keysym name to keysym number
628 */ 668 */
629 STRNCPY (newargstr, str, NEWARGLIM - 1); 669 strncpy (newargstr, str, NEWARGLIM - 1);
630 newargstr[NEWARGLIM - 1] = '\0'; 670 newargstr[NEWARGLIM - 1] = '\0';
631 if (arg == NULL) 671 if (arg == NULL)
632 { 672 {
633 if ((newarg = STRCHR (newargstr, ':')) == NULL) 673 if ((newarg = strchr (newargstr, ':')) == NULL)
634 return -1; 674 return -1;
635 *newarg++ = '\0'; /* terminate keysym name */ 675 *newarg++ = '\0'; /* terminate keysym name */
636 } 676 }
637 if ((sym = XStringToKeysym (newargstr)) == None) 677 if ((sym = XStringToKeysym (newargstr)) == None)
638 return -1; 678 return -1;
644 if (Keysym_map[sym] != NULL) /* already set ? */ 684 if (Keysym_map[sym] != NULL) /* already set ? */
645 return -1; 685 return -1;
646 686
647 if (newarg == NULL) 687 if (newarg == NULL)
648 { 688 {
649 STRNCPY (newargstr, arg, NEWARGLIM - 1); 689 strncpy (newargstr, arg, NEWARGLIM - 1);
650 newargstr[NEWARGLIM - 1] = '\0'; 690 newargstr[NEWARGLIM - 1] = '\0';
651 newarg = newargstr; 691 newarg = newargstr;
652 } 692 }
653 rxvt_Str_trim (newarg); 693 rxvt_Str_trim (newarg);
654 if (*newarg == '\0' || (n = rxvt_Str_escaped (newarg)) == 0) 694 if (*newarg == '\0' || (n = rxvt_Str_escaped (newarg)) == 0)
655 return -1; 695 return -1;
656 MIN_IT (n, 255); 696 MIN_IT (n, 255);
657 key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char)); 697 key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char));
658 698
659 key_string[0] = n; 699 key_string[0] = n;
660 STRNCPY (key_string + 1, newarg, n); 700 strncpy (key_string + 1, newarg, n);
661 Keysym_map[sym] = (unsigned char *)key_string; 701 Keysym_map[sym] = (unsigned char *)key_string;
662 702
663 return 1; 703 return 1;
664} 704}
665 705
671 * the matching algorithm used for memory-save fake resources 711 * the matching algorithm used for memory-save fake resources
672 */ 712 */
673void 713void
674rxvt_term::get_xdefaults (FILE *stream, const char *name) 714rxvt_term::get_xdefaults (FILE *stream, const char *name)
675{ 715{
676 unsigned int len; 716 unsigned int len;
677 char *str, buffer[256]; 717 char *str, buffer[256];
678 718
679 if (stream == NULL) 719 if (stream == NULL)
680 return; 720 return;
681 len = STRLEN (name); 721
722 len = strlen (name);
682 while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) 723 while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL)
683 { 724 {
684 unsigned int entry, n; 725 unsigned int entry, n;
685 726
686 while (*str && isspace (*str)) 727 while (*str && isspace (*str))
687 str++; /* leading whitespace */ 728 str++; /* leading whitespace */
688 729
689 if ((str[len] != '*' && str[len] != '.') 730 if ((str[len] != '*' && str[len] != '.')
690 || (len && STRNCMP (str, name, len))) 731 || (len && strncmp (str, name, len)))
691 continue; 732 continue;
692 str += (len + 1); /* skip `name*' or `name.' */ 733 str += (len + 1); /* skip `name*' or `name.' */
693 734
694# ifdef KEYSYM_RESOURCE 735# ifdef KEYSYM_RESOURCE
695 if (!parse_keysym (str, NULL)) 736 if (!parse_keysym (str, NULL))
696# endif /* KEYSYM_RESOURCE */ 737# endif /* KEYSYM_RESOURCE */
697 for (entry = 0; entry < optList_size (); entry++) 738 for (entry = 0; entry < optList_size (); entry++)
698 { 739 {
699 const char *kw = optList[entry].kw; 740 const char *kw = optList[entry].kw;
700 741
701 if (kw == NULL) 742 if (kw == NULL)
702 continue; 743 continue;
744
703 n = STRLEN (kw); 745 n = strlen (kw);
704 if (str[n] == ':' && rxvt_Str_match (str, kw)) 746 if (str[n] == ':' && rxvt_Str_match (str, kw))
705 { 747 {
706 /* skip `keyword:' */ 748 /* skip `keyword:' */
707 str += (n + 1); 749 str += n + 1;
708 rxvt_Str_trim (str); 750 rxvt_Str_trim (str);
709 n = STRLEN (str); 751 n = strlen (str);
710 if (n && rs[optList[entry].doff] == NULL) 752 if (n && rs[optList[entry].doff] == NULL)
711 { 753 {
712 /* not already set */ 754 /* not already set */
713 int s; 755 int s;
714 char *p = (char *)rxvt_malloc ((n + 1) * sizeof (char)); 756 char *p = 0;
715 757
716 STRCPY (p, str); 758 for (int o = 0;;)
759 {
760 p = (char *)rxvt_realloc (p, o + n + 1);
761 memcpy (p + o, str, n);
762 o += n;
763 p[o] = 0;
764
765 if (o == 0 || p[o - 1] != '\\') // continuation line
766 break;
767
768 o--; // eat "\"
769
770 if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL)
771 break;
772
773 rxvt_Str_trim (str);
774 n = strlen (str);
775 }
776
717 rs[optList[entry].doff] = p; 777 rs[optList[entry].doff] = p;
778 allocated.push_back (p);
779
718 if (optList_isBool (entry)) 780 if (optList_isBool (entry))
719 { 781 {
720 s = STRCASECMP (str, "TRUE") == 0 782 s = strcasecmp (str, "TRUE") == 0
721 || STRCASECMP (str, "YES") == 0 783 || strcasecmp (str, "YES") == 0
722 || STRCASECMP (str, "ON") == 0 784 || strcasecmp (str, "ON") == 0
723 || STRCASECMP (str, "1") == 0; 785 || strcasecmp (str, "1") == 0;
786
724 if (optList_isReverse (entry)) 787 if (optList_isReverse (entry))
725 s = !s; 788 s = !s;
789
726 if (s) 790 if (s)
727 Options |= (optList[entry].flag); 791 options |= optList[entry].flag;
728 else 792 else
729 Options &= ~ (optList[entry].flag); 793 options &= ~optList[entry].flag;
730 } 794 }
731 } 795 }
796
732 break; 797 break;
733 } 798 }
734 } 799 }
735 } 800 }
801
736 rewind (stream); 802 rewind (stream);
737} 803}
738 804
739/*}}} */ 805/*}}} */
740# endif /* ! USE_XGETDEFAULT */ 806# endif /* ! USE_XGETDEFAULT */
751#ifndef NO_RESOURCES 817#ifndef NO_RESOURCES
752 818
753# if defined XAPPLOADDIR 819# if defined XAPPLOADDIR
754# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) 820# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
755 /* Compute the path of the possibly available localized Rxvt file */ 821 /* Compute the path of the possibly available localized Rxvt file */
756 char *localepath = NULL; 822 char *localepath = NULL;
757 823
758 if (locale != NULL) 824 if (locale != NULL)
759 { /* XXX: must limit length of string */ 825 { /* XXX: must limit length of string */
760 localepath = (char *)rxvt_malloc (256); 826 localepath = (char *)rxvt_malloc (256);
761 sprintf (localepath, XAPPLOADDIRLOCALE "/" APL_SUBCLASS, 827 sprintf (localepath, XAPPLOADDIRLOCALE "/" RESCLASS,
762 (int) (258 - sizeof (XAPPLOADDIRLOCALE) - sizeof (APL_SUBCLASS)), 828 (int) (258 - sizeof (XAPPLOADDIRLOCALE) - sizeof (RESCLASS)),
763 locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ 829 locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */
764 } 830 }
765 831
766 { 832 {
767# endif 833# endif
769 835
770# ifdef USE_XGETDEFAULT 836# ifdef USE_XGETDEFAULT
771 /* 837 /*
772 * get resources using the X library function 838 * get resources using the X library function
773 */ 839 */
774 int entry; 840 int entry;
775 841
776# ifdef XrmEnumOneLevel 842# ifdef XrmEnumOneLevel
777 int i; 843 int i;
778 char *displayResource, *xe; 844 char *displayResource, *xe;
779 XrmName name_prefix[3]; 845 XrmName name_prefix[3];
780 XrmClass class_prefix[3]; 846 XrmClass class_prefix[3];
781 XrmDatabase database, rdb1; 847 XrmDatabase database, rdb1;
782 char fname[1024]; 848 char fname[1024];
783 849
784 XrmInitialize (); 850 XrmInitialize ();
785 database = NULL; 851 database = NULL;
786 852
787 /* Get any Xserver defaults */ 853 /* Get any Xserver defaults */
791 database = XrmGetStringDatabase (displayResource); 857 database = XrmGetStringDatabase (displayResource);
792 858
793# ifdef HAVE_EXTRA_XRESOURCE_FILES 859# ifdef HAVE_EXTRA_XRESOURCE_FILES
794 /* Add in ~/.Xdefaults or ~/.Xresources */ 860 /* Add in ~/.Xdefaults or ~/.Xresources */
795 { 861 {
796 char *ptr; 862 char *ptr;
797 863
798 if ((ptr = (char *)getenv ("HOME")) == NULL) 864 if ((ptr = (char *)getenv ("HOME")) == NULL)
799 ptr = "."; 865 ptr = ".";
800 866
801 for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) 867 for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++)
802 { 868 {
803 sprintf (fname, "%-.*s/%s", sizeof (fname) - STRLEN (xnames[i]) - 2, 869 sprintf (fname, "%-.*s/%s", sizeof (fname) - strlen (xnames[i]) - 2,
804 ptr, xnames[i]); 870 ptr, xnames[i]);
805 if ((rdb1 = XrmGetFileDatabase (fname)) != NULL) 871 if ((rdb1 = XrmGetFileDatabase (fname)))
806 { 872 {
807 XrmMergeDatabases (rdb1, &database); 873 XrmMergeDatabases (rdb1, &database);
808# ifndef HAVE_BOTH_XRESOURCE_FILES 874# ifndef HAVE_BOTH_XRESOURCE_FILES
809 break; 875 break;
810# endif 876# endif
822 888
823 /* Add in Rxvt file */ 889 /* Add in Rxvt file */
824# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) 890# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
825 if (localepath == NULL || (rdb1 = XrmGetFileDatabase (localepath)) == NULL) 891 if (localepath == NULL || (rdb1 = XrmGetFileDatabase (localepath)) == NULL)
826# endif 892# endif
827 rdb1 = XrmGetFileDatabase (XAPPLOADDIR "/" APL_SUBCLASS); 893 rdb1 = XrmGetFileDatabase (XAPPLOADDIR "/" RESCLASS);
894
828 if (rdb1 != NULL) 895 if (rdb1 != NULL)
829 XrmMergeDatabases (rdb1, &database); 896 XrmMergeDatabases (rdb1, &database);
830 897
831 /* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */ 898 /* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */
832 if ((xe = (char *)getenv ("XAPPLRESDIR")) != NULL) 899 if ((xe = (char *)getenv ("XAPPLRESDIR")) != NULL)
833 { 900 {
834 sprintf (fname, "%-.*s/" APL_SUBCLASS, sizeof (fname) 901 sprintf (fname, "%-.*s/" RESCLASS, sizeof (fname)
835 - sizeof (APL_SUBCLASS) - 2, xe); 902 - sizeof (RESCLASS) - 2, xe);
836 if ((rdb1 = XrmGetFileDatabase (fname)) != NULL) 903 if ((rdb1 = XrmGetFileDatabase (fname)) != NULL)
837 XrmMergeDatabases (rdb1, &database); 904 XrmMergeDatabases (rdb1, &database);
838 } 905 }
839 906
840 XrmSetDatabase (display, database); 907 XrmSetDatabase (display, database);
852 if (kw == NULL || rs[optList[entry].doff] != NULL) 919 if (kw == NULL || rs[optList[entry].doff] != NULL)
853 continue; /* previously set */ 920 continue; /* previously set */
854 921
855 p = XGetDefault (display, name, kw); 922 p = XGetDefault (display, name, kw);
856 p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); 923 p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw);
857 if (p == NULL || (p0 && STRCMP (p, p0) == 0)) 924 if (p == NULL || (p0 && strcmp (p, p0) == 0))
858 { 925 {
859 p = XGetDefault (display, APL_SUBCLASS, kw); 926 p = XGetDefault (display, RESCLASS, kw);
927#ifdef RESFALLBACK
860 if (p == NULL || (p0 && STRCMP (p, p0) == 0)) 928 if (p == NULL || (p0 && strcmp (p, p0) == 0))
861 p = XGetDefault (display, APL_CLASS, kw); 929 p = XGetDefault (display, RESFALLBACK, kw);
930#endif
862 } 931 }
932
863 if (p == NULL && p0) 933 if (p == NULL && p0)
864 p = p0; 934 p = p0;
935
865 if (p) 936 if (p)
866 { 937 {
867 rs[optList[entry].doff] = p; 938 rs[optList[entry].doff] = p;
868 939
869 if (optList_isBool (entry)) 940 if (optList_isBool (entry))
870 { 941 {
871 s = STRCASECMP (p, "TRUE") == 0 942 s = strcasecmp (p, "TRUE") == 0
872 || STRCASECMP (p, "YES") == 0 943 || strcasecmp (p, "YES") == 0
873 || STRCASECMP (p, "ON") == 0 944 || strcasecmp (p, "ON") == 0
874 || STRCASECMP (p, "1") == 0; 945 || strcasecmp (p, "1") == 0;
875 if (optList_isReverse (entry)) 946 if (optList_isReverse (entry))
876 s = !s; 947 s = !s;
877 if (s) 948 if (s)
878 Options |= (optList[entry].flag); 949 options |= (optList[entry].flag);
879 else 950 else
880 Options &= ~ (optList[entry].flag); 951 options &= ~ (optList[entry].flag);
881 } 952 }
882 } 953 }
883 } 954 }
884 955
885 /* 956 /*
888# ifdef XrmEnumOneLevel 959# ifdef XrmEnumOneLevel
889# ifdef KEYSYM_RESOURCE 960# ifdef KEYSYM_RESOURCE
890 name_prefix[0] = XrmStringToName (name); 961 name_prefix[0] = XrmStringToName (name);
891 name_prefix[1] = XrmStringToName ("keysym"); 962 name_prefix[1] = XrmStringToName ("keysym");
892 name_prefix[2] = NULLQUARK; 963 name_prefix[2] = NULLQUARK;
893 class_prefix[0] = XrmStringToName (APL_SUBCLASS); 964 class_prefix[0] = XrmStringToName (RESCLASS);
894 class_prefix[1] = XrmStringToName ("Keysym"); 965 class_prefix[1] = XrmStringToName ("Keysym");
895 class_prefix[2] = NULLQUARK; 966 class_prefix[2] = NULLQUARK;
896 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ 967 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
897 XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix, 968 XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix,
898 XrmEnumOneLevel, rxvt_define_key, NULL); 969 XrmEnumOneLevel, rxvt_define_key, NULL);
970# ifdef RESFALLBACK
899 name_prefix[0] = XrmStringToName (APL_CLASS); 971 name_prefix[0] = XrmStringToName (RESFALLBACK);
900 name_prefix[1] = XrmStringToName ("keysym"); 972 name_prefix[1] = XrmStringToName ("keysym");
901 class_prefix[0] = XrmStringToName (APL_CLASS); 973 class_prefix[0] = XrmStringToName (RESFALLBACK);
902 class_prefix[1] = XrmStringToName ("Keysym"); 974 class_prefix[1] = XrmStringToName ("Keysym");
903 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ 975 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
904 XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix, 976 XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix,
905 XrmEnumOneLevel, rxvt_define_key, NULL); 977 XrmEnumOneLevel, rxvt_define_key, NULL);
978# endif
906# endif 979# endif
907# endif 980# endif
908 981
909# else /* USE_XGETDEFAULT */ 982# else /* USE_XGETDEFAULT */
910 /* get resources the hard way, but save lots of memory */ 983 /* get resources the hard way, but save lots of memory */
911 FILE *fd = NULL; 984 FILE *fd = NULL;
912 char *home; 985 char *home;
913 986
914 if ((home = getenv ("HOME")) != NULL) 987 if ((home = getenv ("HOME")) != NULL)
915 { 988 {
916 unsigned int i, len = STRLEN (home) + 2; 989 unsigned int i, len = strlen (home) + 2;
917 char *f = NULL; 990 char *f = NULL;
918 991
919 for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) 992 for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++)
920 { 993 {
921 f = (char *)rxvt_realloc (f, (len + STRLEN (xnames[i])) * sizeof (char)); 994 f = (char *)rxvt_realloc (f, (len + strlen (xnames[i])) * sizeof (char));
922 995
923 sprintf (f, "%s/%s", home, xnames[i]); 996 sprintf (f, "%s/%s", home, xnames[i]);
924 997
925 if ((fd = fopen (f, "r")) != NULL) 998 if ((fd = fopen (f, "r")) != NULL)
926 break; 999 break;
948 * Also, use a special sub-class so that we can use either or both of 1021 * Also, use a special sub-class so that we can use either or both of
949 * "XTerm" and "Rxvt" as class names. 1022 * "XTerm" and "Rxvt" as class names.
950 */ 1023 */
951 1024
952 get_xdefaults (fd, name); 1025 get_xdefaults (fd, name);
953 get_xdefaults (fd, APL_SUBCLASS); 1026 get_xdefaults (fd, RESCLASS);
1027# ifdef RESFALLBACK
1028 get_xdefaults (fd, RESFALLBACK);
1029# endif
954 1030
955# if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR) 1031# if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR)
956
957 { 1032 {
958 FILE *ad = NULL; 1033 FILE *ad = NULL;
959 1034
960# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) 1035# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
961 if (localepath == NULL || (ad = fopen (localepath, "r")) == NULL) 1036 if (localepath == NULL || (ad = fopen (localepath, "r")) == NULL)
962# endif 1037# endif
963 ad = fopen (XAPPLOADDIR "/" APL_SUBCLASS, "r"); 1038 ad = fopen (XAPPLOADDIR "/" RESCLASS, "r");
964 if (ad != NULL) 1039 if (ad != NULL)
965 { 1040 {
966 get_xdefaults (ad, APL_SUBCLASS); 1041 get_xdefaults (ad, RESCLASS);
967 get_xdefaults (ad, ""); 1042 get_xdefaults (ad, "");
968 fclose (ad); 1043 fclose (ad);
969 } 1044 }
970 } 1045 }
971# endif /* XAPPLOADDIR */ 1046# endif /* XAPPLOADDIR */
972 1047
973 get_xdefaults (fd, APL_CLASS);
974 get_xdefaults (fd, ""); /* partial match */ 1048 get_xdefaults (fd, ""); /* partial match */
975 if (fd != NULL) 1049 if (fd != NULL)
976 fclose (fd); 1050 fclose (fd);
977# endif /* USE_XGETDEFAULT */ 1051# endif /* USE_XGETDEFAULT */
978 1052
985 free (localepath); 1059 free (localepath);
986# endif 1060# endif
987# endif 1061# endif
988 1062
989#endif /* NO_RESOURCES */ 1063#endif /* NO_RESOURCES */
990
991 /*
992 * even without resources, at least do this setup for command-line
993 * options and command-line long options
994 */
995
996#if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
997 KeySym sym;
998
999 if (rs[Rs_bigfont_key]
1000 && ((sym = XStringToKeysym (rs[Rs_bigfont_key])) != 0))
1001 ks_bigfont = sym;
1002 if (rs[Rs_smallfont_key]
1003 && ((sym = XStringToKeysym (rs[Rs_smallfont_key])) != 0))
1004 ks_smallfont = sym;
1005#endif
1006} 1064}
1007 1065
1008/*}}} */ 1066/*}}} */
1009/*----------------------- end-of-file (C source) -----------------------*/ 1067/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines