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.161 by sf-exg, Sun Dec 18 02:25:12 2011 UTC vs.
Revision 1.169 by sf-exg, Wed Jun 6 22:00:20 2012 UTC

192 RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"), 192 RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"),
193#endif /* NO_CURSORCOLOR */ 193#endif /* NO_CURSORCOLOR */
194 STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), 194 STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"),
195 STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), 195 STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"),
196 STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"), 196 STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"),
197#ifdef BG_IMAGE_FROM_FILE 197#if BG_IMAGE_FROM_FILE
198 RSTRG (Rs_path, "path", "search path"), 198 RSTRG (Rs_path, "path", "search path"),
199 STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"), 199 STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"),
200# if ENABLE_EWMH 200# if ENABLE_EWMH
201 STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), 201 STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"),
202# endif 202# endif
207 STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"), 207 STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold font"),
208 STRG (Rs_italicFont, "italicFont", "fi", "fontname", "italic font"), 208 STRG (Rs_italicFont, "italicFont", "fi", "fontname", "italic font"),
209 STRG (Rs_boldItalicFont, "boldItalicFont", "fbi", "fontname", "bold italic font"), 209 STRG (Rs_boldItalicFont, "boldItalicFont", "fbi", "fontname", "bold italic font"),
210 BOOL (Rs_intensityStyles, "intensityStyles", "is", Opt_intensityStyles, 0, "font styles imply intensity changes"), 210 BOOL (Rs_intensityStyles, "intensityStyles", "is", Opt_intensityStyles, 0, "font styles imply intensity changes"),
211#endif 211#endif
212#ifdef USE_XIM 212#if USE_XIM
213 STRG (Rs_inputMethod, "inputMethod", "im", "name", "name of input method"), 213 STRG (Rs_inputMethod, "inputMethod", "im", "name", "name of input method"),
214 STRG (Rs_preeditType, "preeditType", "pt", "style", "input style: style = OverTheSpot|OffTheSpot|Root"), 214 STRG (Rs_preeditType, "preeditType", "pt", "style", "input style: style = OverTheSpot|OffTheSpot|Root"),
215 STRG (Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"), 215 STRG (Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"),
216 STRG (Rs_imFont, "imFont", "imfont", "fontname", "fontset for styles OverTheSpot and OffTheSpot"), 216 STRG (Rs_imFont, "imFont", "imfont", "fontname", "fontset for styles OverTheSpot and OffTheSpot"),
217#endif /* USE_XIM */ 217#endif /* USE_XIM */
270#endif 270#endif
271#if ISO_14755 271#if ISO_14755
272 BOOL (Rs_iso14755, "iso14755", NULL, Opt_iso14755, 0, NULL), 272 BOOL (Rs_iso14755, "iso14755", NULL, Opt_iso14755, 0, NULL),
273 BOOL (Rs_iso14755_52, "iso14755_52", NULL, Opt_iso14755_52, 0, NULL), 273 BOOL (Rs_iso14755_52, "iso14755_52", NULL, Opt_iso14755_52, 0, NULL),
274#endif 274#endif
275#ifdef HAVE_AFTERIMAGE
276 STRG (Rs_blendtype, "blendType", "blt", "string", "background image blending type - alpha, tint, etc..."),
277#endif
278#ifndef NO_RESOURCES 275#ifndef NO_RESOURCES
279 RINFO ("xrm", "string"), 276 RINFO ("xrm", "string"),
280#endif 277#endif
281#ifdef KEYSYM_RESOURCE 278#ifdef KEYSYM_RESOURCE
282 RINFO ("keysym.sym", "keysym"), 279 RINFO ("keysym.sym", "keysym"),
336#endif 333#endif
337#if defined(ENABLE_TRANSPARENCY) 334#if defined(ENABLE_TRANSPARENCY)
338 "transparent," 335 "transparent,"
339 "tint," 336 "tint,"
340#endif 337#endif
341#if HAVE_AFTERIMAGE
342 "afterimage,"
343#endif
344#if HAVE_PIXBUF 338#if HAVE_PIXBUF
345 "pixbuf," 339 "pixbuf,"
346#endif 340#endif
347#if defined(USE_XIM) 341#if defined(USE_XIM)
348 "XIM," 342 "XIM,"
390#if defined(XTERM_SCROLLBAR) 384#if defined(XTERM_SCROLLBAR)
391 "+xterm" 385 "+xterm"
392#endif 386#endif
393 "\nUsage: "; /* Usage */ 387 "\nUsage: "; /* Usage */
394 388
395#define INDENT 18 389#define INDENT 28
396 390
397const char rxvt_term::resval_undef [] = "<undef>"; 391const char rxvt_term::resval_undef [] = "<undef>";
398const char rxvt_term::resval_on [] = "on"; 392const char rxvt_term::resval_on [] = "on";
399const char rxvt_term::resval_off [] = "off"; 393const char rxvt_term::resval_off [] = "off";
400 394
401/*{{{ usage: */ 395/*{{{ usage: */
402/*----------------------------------------------------------------------*/ 396/*----------------------------------------------------------------------*/
403static void 397void
404rxvt_usage (int type) 398rxvt_term::rxvt_usage (int type)
405{ 399{
406 unsigned int i, col; 400 unsigned int i, col;
407 401
408 rxvt_log ("%s%s%s", releasestring, optionsstring, RESNAME); 402 rxvt_log ("%s%s%s", releasestring, optionsstring, RESNAME);
409 403
417 { 411 {
418 int len = 0; 412 int len = 0;
419 413
420 if (optList[i].arg) 414 if (optList[i].arg)
421 len = strlen (optList[i].arg) + 1; 415 len = strlen (optList[i].arg) + 1;
416
422 assert (optList[i].opt != NULL); 417 assert (optList[i].opt != NULL);
423 len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2 : 0); 418 len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2 : 0);
424 col += len; 419 col += len;
420
425 if (col > 79) 421 if (col > 79)
426 { 422 {
427 /* assume regular width */ 423 /* assume regular width */
428 rxvt_log ("\n"); 424 rxvt_log ("\n");
429 col = 1 + len; 425 col = 1 + len;
430 } 426 }
431 427
432 rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt); 428 rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt);
429
433 if (optList[i].arg) 430 if (optList[i].arg)
434 rxvt_log (" %s]", optList[i].arg); 431 rxvt_log (" %s]", optList[i].arg);
435 else 432 else
436 rxvt_log ("]"); 433 rxvt_log ("]");
437 } 434 }
450 + (optList_isBool (i) ? 0 : 2)), 447 + (optList_isBool (i) ? 0 : 2)),
451 (optList[i].arg ? optList[i].arg : ""), 448 (optList[i].arg ? optList[i].arg : ""),
452 (optList_isBool (i) ? "turn on/off " : ""), 449 (optList_isBool (i) ? "turn on/off " : ""),
453 optList[i].desc); 450 optList[i].desc);
454 } 451 }
452
453#if ENABLE_PERL
454 rxvt_perl.init (this);
455 rxvt_perl.usage (this, 1);
456#endif
457
455 rxvt_log ("\n --help to list long-options"); 458 rxvt_log ("\n --help to list long-options");
456 break; 459 break;
457 460
458 case 2: /* full resource listing */ 461 case 2: /* full resource listing */
459 rxvt_log (" [options] [-e command args]\n\n" 462 rxvt_log (" [options] [-e command args]\n\n"
461 464
462 for (i = 0; i < ecb_array_length (optList); i++) 465 for (i = 0; i < ecb_array_length (optList); i++)
463 if (optList[i].kw != NULL) 466 if (optList[i].kw != NULL)
464 rxvt_log (" %s: %*s%s\n", 467 rxvt_log (" %s: %*s%s\n",
465 optList[i].kw, 468 optList[i].kw,
466 (INDENT - strlen (optList[i].kw)), "", /* XXX */ 469 (INDENT + 2 - strlen (optList[i].kw)), "", /* XXX */
467 (optList_isBool (i) ? "boolean" : optList[i].arg)); 470 (optList_isBool (i) ? "boolean" : optList[i].arg));
471
472#if ENABLE_PERL
473 rxvt_perl.init (this);
474 rxvt_perl.usage (this, 2);
475#endif
476
468 rxvt_log ("\n -help to list options"); 477 rxvt_log ("\n -help to list options");
469 break; 478 break;
470 } 479 }
471 480
472 rxvt_log ("\n\n"); 481 rxvt_log ("\n\n");
537 * default values 546 * default values
538 */ 547 */
539 548
540 if (optList[entry].doff != -1) 549 if (optList[entry].doff != -1)
541 { 550 {
542 if (flag && i+1 == argc) 551 if (flag && i + 1 == argc)
543 rxvt_fatal ("option '%s' requires an argument, aborting.\n", argv [i]); 552 rxvt_fatal ("option '%s' requires an argument, aborting.\n", argv [i]);
544 553
545 rs[optList[entry].doff] = flag ? argv[++i] : resval_undef; 554 rs[optList[entry].doff] = flag ? argv[++i] : resval_undef;
546 } 555 }
547 } 556 }
555 } 564 }
556 } 565 }
557#ifndef NO_RESOURCES 566#ifndef NO_RESOURCES
558 else if (!strcmp (opt, "xrm")) 567 else if (!strcmp (opt, "xrm"))
559 { 568 {
560 if (i+1 < argc) 569 if (i + 1 < argc)
561 XrmPutLineResource (&option_db, argv[++i]); 570 XrmPutLineResource (&option_db, argv[++i]);
562 } 571 }
563#endif 572#endif
564#ifdef KEYSYM_RESOURCE 573#ifdef KEYSYM_RESOURCE
565 else if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1)) 574 else if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1))
566 { 575 {
567 if (i+1 < argc) 576 if (i + 1 < argc)
568 { 577 {
569 char *res = rxvt_temp_buf<char> (strlen (opt) + strlen (argv[++i]) + 6); 578 char *res = rxvt_temp_buf<char> (strlen (opt) + strlen (argv[++i]) + 6);
570 sprintf (res, "*.%s: %s\n", opt, argv[i]); 579 sprintf (res, "*.%s: %s\n", opt, argv[i]);
571 XrmPutLineResource (&option_db, res); 580 XrmPutLineResource (&option_db, res);
572 } 581 }
573 } 582 }
574#endif 583#endif
575 else if (!strcmp (opt, "e")) 584 else if (!strcmp (opt, "e"))
576 { 585 {
577 if (i+1 == argc) 586 if (i + 1 < argc)
578 rxvt_fatal ("option '-e' requires an argument, aborting.\n");
579
580 return (const char **)argv + i + 1; 587 return (const char **)argv + i + 1;
588
589 rxvt_warn ("option '-e' requires an argument, aborting.\n");
590 bad_option = 1;
581 } 591 }
582 else 592 else
583 { 593 {
594#if ENABLE_PERL
595 rxvt_perl.init (this);
596
597 if (int flags = rxvt_perl.parse_resource (this, opt, true, longopt, flag, argv [i + 1]))
598 {
599 if (flags & rxvt_perl.RESOURCE_ARG)
600 {
601 if (i + 1 == argc)
602 {
603 rxvt_warn ("option '%s' requires an argument.\n", argv [i]);
584 bad_option = 1; 604 bad_option = 1;
605 }
606 else
607 ++i;
608 }
609 }
610 else
611#endif
612 {
585 rxvt_warn ("\"%s\": unknown or malformed option.\n", opt); 613 rxvt_warn ("\"%s\": unknown or malformed option.\n", opt);
614 bad_option = 1;
615 }
586 } 616 }
587 } 617 }
588 618
589 if (bad_option) 619 if (bad_option)
590 rxvt_usage (0); 620 rxvt_usage (0);
766 /* 796 /*
767 * Query resources for options that affect us 797 * Query resources for options that affect us
768 */ 798 */
769 for (int entry = 0; entry < ecb_array_length (optList); entry++) 799 for (int entry = 0; entry < ecb_array_length (optList); entry++)
770 { 800 {
771 int s;
772 const char *kw = optList[entry].kw; 801 const char *kw = optList[entry].kw;
773 802
774 if (kw == NULL || rs[optList[entry].doff] != NULL) 803 if (kw == NULL || rs[optList[entry].doff] != NULL)
775 continue; // previously set 804 continue; // previously set
776 805
782 allocated.push_back ((void *)p); 811 allocated.push_back ((void *)p);
783 rs[optList[entry].doff] = p; 812 rs[optList[entry].doff] = p;
784 813
785 if (optList_isBool (entry)) 814 if (optList_isBool (entry))
786 { 815 {
787 s = strcasecmp (p, "TRUE") == 0 816 bool s = parse_bool_resource (p);
788 || strcasecmp (p, "YES") == 0
789 || strcasecmp (p, "ON") == 0
790 || strcasecmp (p, "1") == 0;
791 817
792 if (optList_isReverse (entry)) 818 if (optList_isReverse (entry))
793 s = !s; 819 s = !s;
794 820
795 set_option (optList[entry].index, s); 821 set_option (optList[entry].index, s);
800} 826}
801 827
802void 828void
803rxvt_term::extract_keysym_resources () 829rxvt_term::extract_keysym_resources ()
804{ 830{
805#ifndef NO_RESOURCES 831#if !defined NO_RESOURCES && defined KEYSYM_RESOURCE
832 find_resources ("keysym", "Keysym", XrmEnumOneLevel, rxvt_define_key);
833#endif
834}
835
836#if !defined NO_RESOURCES && defined KEYSYM_RESOURCE
837void
838rxvt_term::find_resources (const char *n_prefix, const char *c_prefix, int mode,
839 Bool (*proc)(XrmDatabase *, XrmBindingList, XrmQuarkList, XrmRepresentation *, XrmValue *, XPointer))
840{
806 /* 841 /*
807 * [R5 or later]: enumerate the resource database 842 * [R5 or later]: enumerate the resource database
808 */ 843 */
809# ifdef KEYSYM_RESOURCE
810 XrmDatabase database = XrmGetDatabase (dpy); 844 XrmDatabase database = XrmGetDatabase (dpy);
811 XrmName name_prefix[3]; 845 XrmName name_prefix[3];
812 XrmClass class_prefix[3]; 846 XrmClass class_prefix[3];
813 847
814 name_prefix[0] = XrmStringToName (rs[Rs_name]); 848 name_prefix[0] = XrmStringToName (rs[Rs_name]);
815 name_prefix[1] = XrmStringToName ("keysym"); 849 name_prefix[1] = XrmStringToName (n_prefix);
816 name_prefix[2] = NULLQUARK; 850 name_prefix[2] = NULLQUARK;
817 class_prefix[0] = XrmStringToName (RESCLASS); 851 class_prefix[0] = XrmStringToName (RESCLASS);
818 class_prefix[1] = XrmStringToName ("Keysym"); 852 class_prefix[1] = XrmStringToName (c_prefix);
819 class_prefix[2] = NULLQUARK; 853 class_prefix[2] = NULLQUARK;
820 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ 854 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
821 XrmEnumerateDatabase (database, name_prefix, class_prefix, 855 XrmEnumerateDatabase (database, name_prefix, class_prefix,
822 XrmEnumOneLevel, rxvt_define_key, NULL); 856 mode, proc, NULL);
823# ifdef RESFALLBACK 857# ifdef RESFALLBACK
824 name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); 858 name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK);
825 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ 859 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
826 XrmEnumerateDatabase (database, name_prefix, class_prefix, 860 XrmEnumerateDatabase (database, name_prefix, class_prefix,
827 XrmEnumOneLevel, rxvt_define_key, NULL); 861 mode, proc, NULL);
828# endif 862# endif
829# endif
830
831#endif /* NO_RESOURCES */
832} 863}
864#endif
833 865
834/*----------------------- end-of-file (C source) -----------------------*/ 866/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines