… | |
… | |
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 | |
37 | static const char *const xnames[2] = { ".Xdefaults", ".Xresources" }; |
36 | static 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() \ |
… | |
… | |
109 | SWCH ("tr", Opt_transparent, NULL), |
108 | SWCH ("tr", Opt_transparent, NULL), |
110 | #if TINTING |
109 | #if TINTING |
111 | STRG (Rs_color + Color_tint, "tintColor", "tint", "color", "tint color"), |
110 | STRG (Rs_color + Color_tint, "tintColor", "tint", "color", "tint color"), |
112 | #endif |
111 | #endif |
113 | #endif |
112 | #endif |
|
|
113 | #ifdef OFF_FOCUS_FADING |
|
|
114 | STRG (Rs_fade, "fading", "fade", "%", "make colors x% darker when urxvt is losing focus."), |
|
|
115 | #endif |
|
|
116 | #ifdef TINTING |
|
|
117 | STRG (Rs_shade, "shading", "sh", "%", "shade background by x% when tinting."), |
|
|
118 | #endif |
114 | BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, "utmp inhibit"), |
119 | BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, "utmp inhibit"), |
115 | #ifndef NO_BELL |
120 | #ifndef NO_BELL |
116 | BOOL (Rs_visualBell, "visualBell", "vb", Opt_visualBell, "visual bell"), |
121 | BOOL (Rs_visualBell, "visualBell", "vb", Opt_visualBell, "visual bell"), |
117 | # if ! defined(NO_MAPALERT) && defined(MAPALERT_OPTION) |
122 | # if ! defined(NO_MAPALERT) && defined(MAPALERT_OPTION) |
118 | BOOL (Rs_mapAlert, "mapAlert", NULL, Opt_mapAlert, NULL), |
123 | BOOL (Rs_mapAlert, "mapAlert", NULL, Opt_mapAlert, NULL), |
… | |
… | |
122 | BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, NULL), |
127 | BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, NULL), |
123 | #endif |
128 | #endif |
124 | #ifdef MOUSE_WHEEL |
129 | #ifdef MOUSE_WHEEL |
125 | BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, NULL), |
130 | BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, NULL), |
126 | #endif |
131 | #endif |
127 | #ifndef NO_FRILLS |
132 | #if ENABLE_FRILLS |
128 | BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, "triple click word selection"), |
133 | BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, "triple click word selection"), |
129 | BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, "enable possibly insecure escape sequences"), |
134 | BOOL (Rs_insecure, "insecure", "insecure", Opt_insecure, "enable possibly insecure escape sequences"), |
130 | #endif |
135 | #endif |
131 | #ifdef CURSOR_BLINK |
136 | #ifdef CURSOR_BLINK |
132 | BOOL (Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"), |
137 | BOOL (Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"), |
… | |
… | |
153 | RSTRG (Rs_color + minBrightCOLOR + 5, "color13", "color"), |
158 | RSTRG (Rs_color + minBrightCOLOR + 5, "color13", "color"), |
154 | RSTRG (Rs_color + minBrightCOLOR + 6, "color14", "color"), |
159 | RSTRG (Rs_color + minBrightCOLOR + 6, "color14", "color"), |
155 | RSTRG (Rs_color + minBrightCOLOR + 7, "color15", "color"), |
160 | RSTRG (Rs_color + minBrightCOLOR + 7, "color15", "color"), |
156 | #endif /* NO_BRIGHTCOLOR */ |
161 | #endif /* NO_BRIGHTCOLOR */ |
157 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
162 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
163 | BOOL (Rs_realBold, "realBold", "rb", Opt_realBold, "use bold fonts for bold text"), |
158 | RSTRG (Rs_color + Color_BD, "colorBD", "color"), |
164 | RSTRG (Rs_color + Color_BD, "colorBD", "color"), |
159 | RSTRG (Rs_color + Color_UL, "colorUL", "color"), |
165 | RSTRG (Rs_color + Color_UL, "colorUL", "color"), |
160 | RSTRG (Rs_color + Color_RV, "colorRV", "color"), |
166 | RSTRG (Rs_color + Color_RV, "colorRV", "color"), |
161 | #endif /* ! NO_BOLD_UNDERLINE_REVERSE */ |
167 | #endif /* ! NO_BOLD_UNDERLINE_REVERSE */ |
162 | #ifdef KEEP_SCROLLCOLOR |
168 | #ifdef KEEP_SCROLLCOLOR |
… | |
… | |
195 | #endif /* NO_CURSORCOLOR */ |
201 | #endif /* NO_CURSORCOLOR */ |
196 | STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), |
202 | STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), |
197 | STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), |
203 | STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), |
198 | STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"), |
204 | STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"), |
199 | STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"), |
205 | STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"), |
200 | #ifndef NO_FRILLS |
206 | #if ENABLE_FRILLS |
201 | STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"), |
207 | STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"), |
202 | STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL), |
208 | STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL), |
203 | STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), |
209 | STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), |
204 | STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"), |
210 | STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"), |
|
|
211 | BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, "borderless window"), |
205 | #endif |
212 | #endif |
206 | #ifndef NO_LINESPACE |
213 | #ifndef NO_LINESPACE |
207 | STRG (Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows"), |
214 | STRG (Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows"), |
208 | #endif |
215 | #endif |
209 | STRG (Rs_scrollBar_thickness, "thickness", "sbt", "number", "scrollbar thickness/width in pixels"), |
216 | STRG (Rs_scrollBar_thickness, "thickness", "sbt", "number", "scrollbar thickness/width in pixels"), |
… | |
… | |
243 | #undef SWCH |
250 | #undef SWCH |
244 | #undef BOOL |
251 | #undef BOOL |
245 | /*}}} */ |
252 | /*}}} */ |
246 | |
253 | |
247 | static const char releasestring[] = "Rxvt v" VERSION " - released: " DATE "\n"; |
254 | static const char releasestring[] = "Rxvt v" VERSION " - released: " DATE "\n"; |
248 | static const char optionsstring[] = "Options: " |
255 | static const char optionsstring[] = "options: " |
|
|
256 | #if XFT |
|
|
257 | "xft," |
|
|
258 | #endif |
|
|
259 | #if UNICODE_3 |
|
|
260 | "unicode3," |
|
|
261 | #endif |
|
|
262 | "encodings=eu+vn" |
|
|
263 | #if ENCODING_JP |
|
|
264 | "+jp" |
|
|
265 | #endif |
|
|
266 | #if ENCODING_JP_EXT |
|
|
267 | "+jp-ext" |
|
|
268 | #endif |
|
|
269 | #if ENCODING_KR |
|
|
270 | "+kr" |
|
|
271 | #endif |
|
|
272 | #if ENCODING_CN |
|
|
273 | "+cn" |
|
|
274 | #endif |
|
|
275 | #if ENCODING_CN_EXT |
|
|
276 | "+cn-ext" |
|
|
277 | #endif |
|
|
278 | "," |
|
|
279 | #if ENABLE_COMBINING |
|
|
280 | "combining," |
|
|
281 | #endif |
|
|
282 | #if TEXT_BLINK |
|
|
283 | "blink," |
|
|
284 | #endif |
|
|
285 | #if OFF_FOCUS_FADING |
|
|
286 | "fade," |
|
|
287 | #endif |
249 | #if defined(XPM_BACKGROUND) |
288 | #if defined(XPM_BACKGROUND) |
250 | "XPM," |
289 | "XPM," |
251 | #endif |
290 | #endif |
252 | #if defined(TRANSPARENT) |
291 | #if defined(TRANSPARENT) |
253 | "transparent," |
292 | "transparent," |
254 | #endif |
293 | #endif |
|
|
294 | #if TINTING |
|
|
295 | "tint," |
|
|
296 | #endif |
255 | #if defined(UTMP_SUPPORT) |
297 | #if defined(UTMP_SUPPORT) |
256 | "utmp," |
298 | "utmp," |
257 | #endif |
299 | #endif |
258 | #if defined(MENUBAR) |
300 | #if defined(MENUBAR) |
259 | "menubar," |
301 | "menubar," |
260 | #endif |
|
|
261 | #if !defined(NO_FRILLS) |
|
|
262 | "frills," |
|
|
263 | #endif |
|
|
264 | #if !defined(NO_LINESPACE) |
|
|
265 | "linespace," |
|
|
266 | #endif |
|
|
267 | #if defined(PREFER_24BIT) |
|
|
268 | "24bit," |
|
|
269 | #endif |
302 | #endif |
270 | #if defined(USE_XIM) |
303 | #if defined(USE_XIM) |
271 | "XIM," |
304 | "XIM," |
272 | #endif |
305 | #endif |
273 | "scrollbars=" |
306 | "scrollbars=" |
… | |
… | |
301 | "no_backspace," |
334 | "no_backspace," |
302 | #endif |
335 | #endif |
303 | #if defined(NO_DELETE_KEY) |
336 | #if defined(NO_DELETE_KEY) |
304 | "no_delete," |
337 | "no_delete," |
305 | #endif |
338 | #endif |
|
|
339 | #if EIGHT_BIT_CONTROLS |
|
|
340 | "8bitctrls," |
|
|
341 | #endif |
306 | #if !defined(NO_STRINGS) |
342 | #if !defined(NO_STRINGS) |
307 | "strings," |
343 | "strings," |
308 | #endif |
344 | #endif |
|
|
345 | #if defined(ENABLE_FRILLS) |
|
|
346 | "frills," |
|
|
347 | #endif |
|
|
348 | #if !defined(NO_LINESPACE) |
|
|
349 | "linespace," |
|
|
350 | #endif |
|
|
351 | #if defined(PREFER_24BIT) |
|
|
352 | "24bit," |
|
|
353 | #endif |
|
|
354 | #if defined(SELECTION_SCROLLING) |
|
|
355 | "selectionscrolling," |
|
|
356 | #endif |
|
|
357 | #if MOUSE_WHEEL |
|
|
358 | "wheel," |
|
|
359 | #endif |
|
|
360 | #if MOUSE_SLIP_WHEELING |
|
|
361 | "slipwheel," |
|
|
362 | #endif |
|
|
363 | #if defined(SMART_RESIZE) |
|
|
364 | "smart-resize," |
|
|
365 | #endif |
309 | #if defined(TTY_256COLOR) |
366 | #if defined(TTY_256COLOR) |
310 | "256colour," |
367 | "256colour," |
|
|
368 | #endif |
|
|
369 | #if defined(CURSOR_BLINK) |
|
|
370 | "cursorBlink," |
|
|
371 | #endif |
|
|
372 | #if defined(POINTER_BLANK) |
|
|
373 | "pointerBlank," |
311 | #endif |
374 | #endif |
312 | #if defined(NO_RESOURCES) |
375 | #if defined(NO_RESOURCES) |
313 | "NoResources" |
376 | "NoResources" |
314 | #else |
377 | #else |
315 | # if defined(USE_XGETDEFAULT) |
378 | # if defined(USE_XGETDEFAULT) |
… | |
… | |
348 | len++; /* account for space */ |
411 | len++; /* account for space */ |
349 | } |
412 | } |
350 | #ifdef DEBUG_STRICT |
413 | #ifdef DEBUG_STRICT |
351 | assert (optList[i].opt != NULL); |
414 | assert (optList[i].opt != NULL); |
352 | #endif |
415 | #endif |
353 | len += 4 + STRLEN (optList[i].opt) + (optList_isBool (i) ? 2: 0); |
416 | len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2: 0); |
354 | col += len; |
417 | col += len; |
355 | if (col > 79) |
418 | if (col > 79) |
356 | { /* assume regular width */ |
419 | { /* assume regular width */ |
357 | rxvt_log ("\n"); |
420 | rxvt_log ("\n"); |
358 | col = 1 + len; |
421 | col = 1 + len; |
… | |
… | |
375 | #ifdef DEBUG_STRICT |
438 | #ifdef DEBUG_STRICT |
376 | assert (optList[i].opt != NULL); |
439 | assert (optList[i].opt != NULL); |
377 | #endif |
440 | #endif |
378 | rxvt_log (" %s%s %-*s%s%s\n", |
441 | rxvt_log (" %s%s %-*s%s%s\n", |
379 | (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, |
442 | (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, |
380 | (INDENT - STRLEN (optList[i].opt) |
443 | (INDENT - strlen (optList[i].opt) |
381 | + (optList_isBool (i) ? 0 : 2)), |
444 | + (optList_isBool (i) ? 0 : 2)), |
382 | (optList[i].arg ? optList[i].arg : ""), |
445 | (optList[i].arg ? optList[i].arg : ""), |
383 | (optList_isBool (i) ? "turn on/off " : ""), |
446 | (optList_isBool (i) ? "turn on/off " : ""), |
384 | optList[i].desc); |
447 | optList[i].desc); |
385 | } |
448 | } |
… | |
… | |
392 | |
455 | |
393 | for (i = 0; i < optList_size (); i++) |
456 | for (i = 0; i < optList_size (); i++) |
394 | if (optList[i].kw != NULL) |
457 | if (optList[i].kw != NULL) |
395 | rxvt_log (" %s: %*s%s\n", |
458 | rxvt_log (" %s: %*s%s\n", |
396 | optList[i].kw, |
459 | optList[i].kw, |
397 | (INDENT - STRLEN (optList[i].kw)), "", /* XXX */ |
460 | (INDENT - strlen (optList[i].kw)), "", /* XXX */ |
398 | (optList_isBool (i) ? "boolean" : optList[i].arg)); |
461 | (optList_isBool (i) ? "boolean" : optList[i].arg)); |
399 | #ifdef KEYSYM_RESOURCE |
462 | #ifdef KEYSYM_RESOURCE |
400 | rxvt_log (" " "keysym.sym" ": %*s%s\n", |
463 | rxvt_log (" " "keysym.sym" ": %*s%s\n", |
401 | (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */ |
464 | (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */ |
402 | "keysym"); |
465 | "keysym"); |
… | |
… | |
445 | bad_option = 1; |
508 | bad_option = 1; |
446 | rxvt_warn ("\"%s\": malformed option.\n", opt); |
509 | rxvt_warn ("\"%s\": malformed option.\n", opt); |
447 | continue; |
510 | continue; |
448 | } |
511 | } |
449 | |
512 | |
450 | if (!STRCMP (opt, "help")) |
513 | if (!strcmp (opt, "help")) |
451 | rxvt_usage (longopt ? 2 : 1); |
514 | rxvt_usage (longopt ? 2 : 1); |
452 | if (!STRCMP (opt, "h")) |
515 | if (!strcmp (opt, "h")) |
453 | rxvt_usage (0); |
516 | rxvt_usage (0); |
454 | |
517 | |
455 | /* feature: always try to match long-options */ |
518 | /* feature: always try to match long-options */ |
456 | for (entry = 0; entry < optList_size (); entry++) |
519 | for (entry = 0; entry < optList_size (); entry++) |
457 | if ((optList[entry].kw && !STRCMP (opt, optList[entry].kw)) |
520 | if ((optList[entry].kw && !strcmp (opt, optList[entry].kw)) |
458 | || (!longopt |
521 | || (!longopt |
459 | && optList[entry].opt && !STRCMP (opt, optList[entry].opt))) |
522 | && optList[entry].opt && !strcmp (opt, optList[entry].opt))) |
460 | break; |
523 | break; |
461 | |
524 | |
462 | if (entry < optList_size ()) |
525 | if (entry < optList_size ()) |
463 | { |
526 | { |
464 | if (optList_isReverse (entry)) |
527 | if (optList_isReverse (entry)) |
465 | flag = flag == On ? Off : On; |
528 | flag = flag == On ? Off : On; |
|
|
529 | |
466 | if (optList_strlen (entry)) |
530 | if (optList_strlen (entry)) |
467 | { /* string value */ |
|
|
468 | const char *str = argv[++i]; |
|
|
469 | |
|
|
470 | #ifdef DEBUG_RESOURCES |
|
|
471 | fprintf (stderr, "string (%s,%s) = ", |
|
|
472 | optList[entry].opt ? optList[entry].opt : "nil", |
|
|
473 | optList[entry].kw ? optList[entry].kw : "nil"); |
|
|
474 | #endif |
|
|
475 | if (flag == On && str && (optList[entry].doff != -1)) |
|
|
476 | { |
531 | { |
477 | #ifdef DEBUG_RESOURCES |
|
|
478 | fprintf (stderr, "\"%s\"\n", str); |
|
|
479 | #endif |
|
|
480 | rs[optList[entry].doff] = str; |
|
|
481 | /* |
532 | /* |
482 | * special cases are handled in main.c:main () to allow |
533 | * special cases are handled in main.c:main () to allow |
483 | * X resources to set these values before we settle for |
534 | * X resources to set these values before we settle for |
484 | * default values |
535 | * default values |
485 | */ |
536 | */ |
486 | } |
|
|
487 | #ifdef DEBUG_RESOURCES |
|
|
488 | else |
|
|
489 | fprintf (stderr, "???\n"); |
|
|
490 | #endif |
|
|
491 | |
537 | |
|
|
538 | if (optList[entry].doff != -1) |
|
|
539 | rs[optList[entry].doff] = flag == On && argv[i+1] |
|
|
540 | ? argv[++i] : 0; |
492 | } |
541 | } |
493 | else |
542 | else |
494 | { /* boolean value */ |
543 | { /* boolean value */ |
495 | #ifdef DEBUG_RESOURCES |
544 | #ifdef DEBUG_RESOURCES |
496 | fprintf (stderr, "boolean (%s,%s) = %s\n", |
545 | fprintf (stderr, "boolean (%s,%s) = %s\n", |
497 | optList[entry].opt, optList[entry].kw, flag); |
546 | optList[entry].opt, optList[entry].kw, flag); |
498 | #endif |
547 | #endif |
499 | if (flag == On) |
548 | if (flag == On) |
500 | Options |= (optList[entry].flag); |
549 | options |= (optList[entry].flag); |
501 | else |
550 | else |
502 | Options &= ~ (optList[entry].flag); |
551 | options &= ~ (optList[entry].flag); |
503 | |
552 | |
504 | if (optList[entry].doff != -1) |
553 | if (optList[entry].doff != -1) |
505 | rs[optList[entry].doff] = flag; |
554 | rs[optList[entry].doff] = flag; |
506 | } |
555 | } |
507 | } |
556 | } |
508 | else |
557 | else |
509 | #ifdef KEYSYM_RESOURCE |
558 | #ifdef KEYSYM_RESOURCE |
510 | /* if (!STRNCMP (opt, "keysym.", sizeof ("keysym.") - 1)) */ |
559 | /* if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1)) */ |
511 | if (rxvt_Str_match (opt, "keysym.")) |
560 | if (rxvt_Str_match (opt, "keysym.")) |
512 | { |
561 | { |
513 | const char *str = argv[++i]; |
562 | const char *str = argv[++i]; |
514 | |
563 | |
515 | if (str != NULL) |
564 | if (str != NULL) |
… | |
… | |
584 | { |
633 | { |
585 | if (str[0] == '0' && toupper (str[1]) == 'X') |
634 | if (str[0] == '0' && toupper (str[1]) == 'X') |
586 | str += 2; |
635 | str += 2; |
587 | if (arg) |
636 | if (arg) |
588 | { |
637 | { |
589 | if (sscanf (str, (STRCHR (str, ':') ? "%x:" : "%x"), &sym) != 1) |
638 | if (sscanf (str, (strchr (str, ':') ? "%x:" : "%x"), &sym) != 1) |
590 | return -1; |
639 | return -1; |
591 | } |
640 | } |
592 | else |
641 | else |
593 | { |
642 | { |
594 | if (sscanf (str, "%x:", &sym) != 1) |
643 | if (sscanf (str, "%x:", &sym) != 1) |
595 | return -1; |
644 | return -1; |
596 | |
645 | |
597 | /* cue to ':', it's there since sscanf () worked */ |
646 | /* cue to ':', it's there since sscanf () worked */ |
598 | STRNCPY (newargstr, STRCHR (str, ':') + 1, NEWARGLIM - 1); |
647 | strncpy (newargstr, strchr (str, ':') + 1, NEWARGLIM - 1); |
599 | newargstr[NEWARGLIM - 1] = '\0'; |
648 | newargstr[NEWARGLIM - 1] = '\0'; |
600 | newarg = newargstr; |
649 | newarg = newargstr; |
601 | } |
650 | } |
602 | } |
651 | } |
603 | else |
652 | else |
604 | { |
653 | { |
605 | /* |
654 | /* |
606 | * convert keysym name to keysym number |
655 | * convert keysym name to keysym number |
607 | */ |
656 | */ |
608 | STRNCPY (newargstr, str, NEWARGLIM - 1); |
657 | strncpy (newargstr, str, NEWARGLIM - 1); |
609 | newargstr[NEWARGLIM - 1] = '\0'; |
658 | newargstr[NEWARGLIM - 1] = '\0'; |
610 | if (arg == NULL) |
659 | if (arg == NULL) |
611 | { |
660 | { |
612 | if ((newarg = STRCHR (newargstr, ':')) == NULL) |
661 | if ((newarg = strchr (newargstr, ':')) == NULL) |
613 | return -1; |
662 | return -1; |
614 | *newarg++ = '\0'; /* terminate keysym name */ |
663 | *newarg++ = '\0'; /* terminate keysym name */ |
615 | } |
664 | } |
616 | if ((sym = XStringToKeysym (newargstr)) == None) |
665 | if ((sym = XStringToKeysym (newargstr)) == None) |
617 | return -1; |
666 | return -1; |
… | |
… | |
623 | if (Keysym_map[sym] != NULL) /* already set ? */ |
672 | if (Keysym_map[sym] != NULL) /* already set ? */ |
624 | return -1; |
673 | return -1; |
625 | |
674 | |
626 | if (newarg == NULL) |
675 | if (newarg == NULL) |
627 | { |
676 | { |
628 | STRNCPY (newargstr, arg, NEWARGLIM - 1); |
677 | strncpy (newargstr, arg, NEWARGLIM - 1); |
629 | newargstr[NEWARGLIM - 1] = '\0'; |
678 | newargstr[NEWARGLIM - 1] = '\0'; |
630 | newarg = newargstr; |
679 | newarg = newargstr; |
631 | } |
680 | } |
632 | rxvt_Str_trim (newarg); |
681 | rxvt_Str_trim (newarg); |
633 | if (*newarg == '\0' || (n = rxvt_Str_escaped (newarg)) == 0) |
682 | if (*newarg == '\0' || (n = rxvt_Str_escaped (newarg)) == 0) |
634 | return -1; |
683 | return -1; |
635 | MIN_IT (n, 255); |
684 | MIN_IT (n, 255); |
636 | key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char)); |
685 | key_string = (char *)rxvt_malloc ((n + 1) * sizeof (char)); |
637 | |
686 | |
638 | key_string[0] = n; |
687 | key_string[0] = n; |
639 | STRNCPY (key_string + 1, newarg, n); |
688 | strncpy (key_string + 1, newarg, n); |
640 | Keysym_map[sym] = (unsigned char *)key_string; |
689 | Keysym_map[sym] = (unsigned char *)key_string; |
641 | |
690 | |
642 | return 1; |
691 | return 1; |
643 | } |
692 | } |
644 | |
693 | |
… | |
… | |
656 | char *str, buffer[256]; |
705 | char *str, buffer[256]; |
657 | |
706 | |
658 | if (stream == NULL) |
707 | if (stream == NULL) |
659 | return; |
708 | return; |
660 | |
709 | |
661 | len = STRLEN (name); |
710 | len = strlen (name); |
662 | while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) |
711 | while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) |
663 | { |
712 | { |
664 | unsigned int entry, n; |
713 | unsigned int entry, n; |
665 | |
714 | |
666 | while (*str && isspace (*str)) |
715 | while (*str && isspace (*str)) |
667 | str++; /* leading whitespace */ |
716 | str++; /* leading whitespace */ |
668 | |
717 | |
669 | if ((str[len] != '*' && str[len] != '.') |
718 | if ((str[len] != '*' && str[len] != '.') |
670 | || (len && STRNCMP (str, name, len))) |
719 | || (len && strncmp (str, name, len))) |
671 | continue; |
720 | continue; |
672 | str += (len + 1); /* skip `name*' or `name.' */ |
721 | str += (len + 1); /* skip `name*' or `name.' */ |
673 | |
722 | |
674 | # ifdef KEYSYM_RESOURCE |
723 | # ifdef KEYSYM_RESOURCE |
675 | if (!parse_keysym (str, NULL)) |
724 | if (!parse_keysym (str, NULL)) |
… | |
… | |
679 | const char *kw = optList[entry].kw; |
728 | const char *kw = optList[entry].kw; |
680 | |
729 | |
681 | if (kw == NULL) |
730 | if (kw == NULL) |
682 | continue; |
731 | continue; |
683 | |
732 | |
684 | n = STRLEN (kw); |
733 | n = strlen (kw); |
685 | if (str[n] == ':' && rxvt_Str_match (str, kw)) |
734 | if (str[n] == ':' && rxvt_Str_match (str, kw)) |
686 | { |
735 | { |
687 | /* skip `keyword:' */ |
736 | /* skip `keyword:' */ |
688 | str += n + 1; |
737 | str += n + 1; |
689 | rxvt_Str_trim (str); |
738 | rxvt_Str_trim (str); |
690 | n = STRLEN (str); |
739 | n = strlen (str); |
691 | if (n && rs[optList[entry].doff] == NULL) |
740 | if (n && rs[optList[entry].doff] == NULL) |
692 | { |
741 | { |
693 | /* not already set */ |
742 | /* not already set */ |
694 | int s; |
743 | int s; |
695 | char *p = 0; |
744 | char *p = 0; |
696 | |
745 | |
697 | for (int o = 0;;) |
746 | for (int o = 0;;) |
698 | { |
747 | { |
699 | p = (char *)rxvt_realloc (p, o + n + 1); |
748 | p = (char *)rxvt_realloc (p, o + n + 1); |
700 | MEMCPY (p + o, str, n); |
749 | memcpy (p + o, str, n); |
701 | o += n; |
750 | o += n; |
702 | p[o] = 0; |
751 | p[o] = 0; |
703 | |
752 | |
704 | if (o == 0 || p[o - 1] != '\\') // continuation line |
753 | if (o == 0 || p[o - 1] != '\\') // continuation line |
705 | break; |
754 | break; |
… | |
… | |
708 | |
757 | |
709 | if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL) |
758 | if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL) |
710 | break; |
759 | break; |
711 | |
760 | |
712 | rxvt_Str_trim (str); |
761 | rxvt_Str_trim (str); |
713 | n = STRLEN (str); |
762 | n = strlen (str); |
714 | } |
763 | } |
715 | |
764 | |
716 | rs[optList[entry].doff] = p; |
765 | rs[optList[entry].doff] = p; |
717 | allocated.push_back (p); |
766 | allocated.push_back (p); |
718 | |
767 | |
719 | if (optList_isBool (entry)) |
768 | if (optList_isBool (entry)) |
720 | { |
769 | { |
721 | s = STRCASECMP (str, "TRUE") == 0 |
770 | s = strcasecmp (str, "TRUE") == 0 |
722 | || STRCASECMP (str, "YES") == 0 |
771 | || strcasecmp (str, "YES") == 0 |
723 | || STRCASECMP (str, "ON") == 0 |
772 | || strcasecmp (str, "ON") == 0 |
724 | || STRCASECMP (str, "1") == 0; |
773 | || strcasecmp (str, "1") == 0; |
725 | |
774 | |
726 | if (optList_isReverse (entry)) |
775 | if (optList_isReverse (entry)) |
727 | s = !s; |
776 | s = !s; |
728 | |
777 | |
729 | if (s) |
778 | if (s) |
730 | Options |= optList[entry].flag; |
779 | options |= optList[entry].flag; |
731 | else |
780 | else |
732 | Options &= ~optList[entry].flag; |
781 | options &= ~optList[entry].flag; |
733 | } |
782 | } |
734 | } |
783 | } |
735 | |
784 | |
736 | break; |
785 | break; |
737 | } |
786 | } |
… | |
… | |
803 | if ((ptr = (char *)getenv ("HOME")) == NULL) |
852 | if ((ptr = (char *)getenv ("HOME")) == NULL) |
804 | ptr = "."; |
853 | ptr = "."; |
805 | |
854 | |
806 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
855 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
807 | { |
856 | { |
808 | sprintf (fname, "%-.*s/%s", sizeof (fname) - STRLEN (xnames[i]) - 2, |
857 | sprintf (fname, "%-.*s/%s", sizeof (fname) - strlen (xnames[i]) - 2, |
809 | ptr, xnames[i]); |
858 | ptr, xnames[i]); |
810 | if ((rdb1 = XrmGetFileDatabase (fname))) |
859 | if ((rdb1 = XrmGetFileDatabase (fname))) |
811 | { |
860 | { |
812 | XrmMergeDatabases (rdb1, &database); |
861 | XrmMergeDatabases (rdb1, &database); |
813 | # ifndef HAVE_BOTH_XRESOURCE_FILES |
862 | # ifndef HAVE_BOTH_XRESOURCE_FILES |
… | |
… | |
858 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
907 | if (kw == NULL || rs[optList[entry].doff] != NULL) |
859 | continue; /* previously set */ |
908 | continue; /* previously set */ |
860 | |
909 | |
861 | p = XGetDefault (display, name, kw); |
910 | p = XGetDefault (display, name, kw); |
862 | p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); |
911 | p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); |
863 | if (p == NULL || (p0 && STRCMP (p, p0) == 0)) |
912 | if (p == NULL || (p0 && strcmp (p, p0) == 0)) |
864 | { |
913 | { |
865 | p = XGetDefault (display, RESCLASS, kw); |
914 | p = XGetDefault (display, RESCLASS, kw); |
866 | #ifdef RESFALLBACK |
915 | #ifdef RESFALLBACK |
867 | if (p == NULL || (p0 && STRCMP (p, p0) == 0)) |
916 | if (p == NULL || (p0 && strcmp (p, p0) == 0)) |
868 | p = XGetDefault (display, RESFALLBACK, kw); |
917 | p = XGetDefault (display, RESFALLBACK, kw); |
869 | #endif |
918 | #endif |
870 | } |
919 | } |
871 | |
920 | |
872 | if (p == NULL && p0) |
921 | if (p == NULL && p0) |
… | |
… | |
876 | { |
925 | { |
877 | rs[optList[entry].doff] = p; |
926 | rs[optList[entry].doff] = p; |
878 | |
927 | |
879 | if (optList_isBool (entry)) |
928 | if (optList_isBool (entry)) |
880 | { |
929 | { |
881 | s = STRCASECMP (p, "TRUE") == 0 |
930 | s = strcasecmp (p, "TRUE") == 0 |
882 | || STRCASECMP (p, "YES") == 0 |
931 | || strcasecmp (p, "YES") == 0 |
883 | || STRCASECMP (p, "ON") == 0 |
932 | || strcasecmp (p, "ON") == 0 |
884 | || STRCASECMP (p, "1") == 0; |
933 | || strcasecmp (p, "1") == 0; |
885 | if (optList_isReverse (entry)) |
934 | if (optList_isReverse (entry)) |
886 | s = !s; |
935 | s = !s; |
887 | if (s) |
936 | if (s) |
888 | Options |= (optList[entry].flag); |
937 | options |= (optList[entry].flag); |
889 | else |
938 | else |
890 | Options &= ~ (optList[entry].flag); |
939 | options &= ~ (optList[entry].flag); |
891 | } |
940 | } |
892 | } |
941 | } |
893 | } |
942 | } |
894 | |
943 | |
895 | /* |
944 | /* |
… | |
… | |
923 | FILE *fd = NULL; |
972 | FILE *fd = NULL; |
924 | char *home; |
973 | char *home; |
925 | |
974 | |
926 | if ((home = getenv ("HOME")) != NULL) |
975 | if ((home = getenv ("HOME")) != NULL) |
927 | { |
976 | { |
928 | unsigned int i, len = STRLEN (home) + 2; |
977 | unsigned int i, len = strlen (home) + 2; |
929 | char *f = NULL; |
978 | char *f = NULL; |
930 | |
979 | |
931 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
980 | for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) |
932 | { |
981 | { |
933 | f = (char *)rxvt_realloc (f, (len + STRLEN (xnames[i])) * sizeof (char)); |
982 | f = (char *)rxvt_realloc (f, (len + strlen (xnames[i])) * sizeof (char)); |
934 | |
983 | |
935 | sprintf (f, "%s/%s", home, xnames[i]); |
984 | sprintf (f, "%s/%s", home, xnames[i]); |
936 | |
985 | |
937 | if ((fd = fopen (f, "r")) != NULL) |
986 | if ((fd = fopen (f, "r")) != NULL) |
938 | break; |
987 | break; |