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.12 by pcg, Sun Feb 22 08:09:38 2004 UTC vs.
Revision 1.19 by pcg, Mon Mar 22 15:15:04 2004 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: xdefaults.c 2 * File: xdefaults.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: xdefaults.C,v 1.12 2004/02/22 08:09:38 pcg Exp $ 4 * $Id: xdefaults.C,v 1.19 2004/03/22 15:15:04 pcg Exp $
5 * 5 *
6 * All portions of code are copyright by their respective author/s. 6 * All portions of code are copyright by their respective author/s.
7 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> 7 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
8 * - original version 8 * - original version
9 * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca> 9 * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca>
130 BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, NULL), 130 BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, NULL),
131#endif 131#endif
132#ifdef MOUSE_WHEEL 132#ifdef MOUSE_WHEEL
133 BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage, 133 BOOL (Rs_mouseWheelScrollPage, "mouseWheelScrollPage", NULL, Opt_mouseWheelScrollPage,
134 NULL), 134 NULL),
135#endif
136#ifdef MULTICHAR_SET
137 BOOL (Rs_mc_hack, "multibyte_cursor", "mcc", Opt_mc_hack,
138 "Multibyte character cursor movement"),
139#endif 135#endif
140#ifndef NO_FRILLS 136#ifndef NO_FRILLS
141 BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords, 137 BOOL (Rs_tripleclickwords, "tripleclickwords", "tcw", Opt_tripleclickwords,
142 "triple click word selection"), 138 "triple click word selection"),
143#endif 139#endif
244 RSTRG (Rs_scrollBar_align, "scrollBar_align", "mode"), 240 RSTRG (Rs_scrollBar_align, "scrollBar_align", "mode"),
245#endif 241#endif
246#ifdef PRINTPIPE 242#ifdef PRINTPIPE
247 RSTRG (Rs_print_pipe, "print-pipe", "string"), 243 RSTRG (Rs_print_pipe, "print-pipe", "string"),
248#endif 244#endif
249#if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
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", 245 STRG (Rs_modifier, "modifier", "mod", "modifier",
254 "meta modifier = alt|meta|hyper|super|mod1|...|mod5"), 246 "meta modifier = alt|meta|hyper|super|mod1|...|mod5"),
255 INFO ("xrm", "string", "X resource"), 247 INFO ("xrm", "string", "X resource"),
256#ifdef CUTCHAR_RESOURCE 248#ifdef CUTCHAR_RESOURCE
257 RSTRG (Rs_cutchars, "cutchars", "string"), 249 RSTRG (Rs_cutchars, "cutchars", "string"),
258#endif /* CUTCHAR_RESOURCE */ 250#endif /* CUTCHAR_RESOURCE */
259#ifdef ACS_ASCII
260 RSTRG (Rs_acs_chars, "acsChars", "string"),
261#endif /* ACS_ASCII */
262 RSTRG (Rs_answerbackstring, "answerbackString", "string"), 251 RSTRG (Rs_answerbackstring, "answerbackString", "string"),
263 INFO ("e", "command arg ...", "command to execute") 252 INFO ("e", "command arg ...", "command to execute")
264 }; 253 };
265 254
266#undef INFO 255#undef INFO
294 "24bit," 283 "24bit,"
295#endif 284#endif
296#if defined(USE_XIM) 285#if defined(USE_XIM)
297 "XIM," 286 "XIM,"
298#endif 287#endif
299#if defined(MULTICHAR_SET)
300 "multichar_languages,"
301#endif
302 "scrollbars=" 288 "scrollbars="
303#if !defined(HAVE_SCROLLBARS) 289#if !defined(HAVE_SCROLLBARS)
304 "NONE" 290 "NONE"
305#else 291#else
292# if defined(PLAIN_SCROLLBAR)
293 "plain"
294# if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR)
295 "+"
296# endif
297# endif
306# if defined(RXVT_SCROLLBAR) 298# if defined(RXVT_SCROLLBAR)
307 "rxvt" 299 "rxvt"
308# if defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) 300# if defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR)
309 "+" 301 "+"
310# endif 302# endif
348/*{{{ usage: */ 340/*{{{ usage: */
349/*----------------------------------------------------------------------*/ 341/*----------------------------------------------------------------------*/
350static void 342static void
351rxvt_usage (int type) 343rxvt_usage (int type)
352{ 344{
353 unsigned int i, col; 345 unsigned int i, col;
354 346
355 write (STDERR_FILENO, releasestring, sizeof (releasestring) - 1); 347 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 348
359 switch (type) 349 switch (type)
360 { 350 {
361 case 0: /* brief listing */ 351 case 0: /* brief listing */
362 fprintf (stderr, " [-help] [--help]\n"); 352 rxvt_log (" [-help] [--help]\n");
353
363 for (col = 1, i = 0; i < optList_size (); i++) 354 for (col = 1, i = 0; i < optList_size (); i++)
364 if (optList[i].desc != NULL) 355 if (optList[i].desc != NULL)
365 { 356 {
366 int len = 0; 357 int len = 0;
367 358
376#endif 367#endif
377 len += 4 + STRLEN (optList[i].opt) + (optList_isBool (i) ? 2: 0); 368 len += 4 + STRLEN (optList[i].opt) + (optList_isBool (i) ? 2: 0);
378 col += len; 369 col += len;
379 if (col > 79) 370 if (col > 79)
380 { /* assume regular width */ 371 { /* assume regular width */
381 putc ('\n', stderr); 372 rxvt_log ("\n");
382 col = 1 + len; 373 col = 1 + len;
383 } 374 }
375
384 fprintf (stderr, " [-%s%s", (optList_isBool (i) ? "/+" : ""), 376 rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt);
385 optList[i].opt);
386 if (optList_strlen (i)) 377 if (optList_strlen (i))
387 fprintf (stderr, " %s]", optList[i].arg); 378 rxvt_log (" %s]", optList[i].arg);
388 else 379 else
389 fprintf (stderr, "]"); 380 rxvt_log ("]");
390 } 381 }
391 break; 382 break;
392 383
393 case 1: /* full command-line listing */ 384 case 1: /* full command-line listing */
394 fprintf (stderr, " [options] [-e command args]\n\n" 385 rxvt_log (" [options] [-e command args]\n\nwhere options include:\n");
395 "where options include:\n"); 386
396 for (i = 0; i < optList_size (); i++) 387 for (i = 0; i < optList_size (); i++)
397 if (optList[i].desc != NULL) 388 if (optList[i].desc != NULL)
398 { 389 {
399#ifdef DEBUG_STRICT 390#ifdef DEBUG_STRICT
400 assert (optList[i].opt != NULL); 391 assert (optList[i].opt != NULL);
401#endif 392#endif
402 fprintf (stderr, " %s%s %-*s%s%s\n", 393 rxvt_log (" %s%s %-*s%s%s\n",
403 (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, 394 (optList_isBool (i) ? "-/+" : "-"), optList[i].opt,
404 (INDENT - STRLEN (optList[i].opt) 395 (INDENT - STRLEN (optList[i].opt)
405 + (optList_isBool (i) ? 0 : 2)), 396 + (optList_isBool (i) ? 0 : 2)),
406 (optList[i].arg ? optList[i].arg : ""), 397 (optList[i].arg ? optList[i].arg : ""),
407 (optList_isBool (i) ? "turn on/off " : ""), 398 (optList_isBool (i) ? "turn on/off " : ""),
408 optList[i].desc); 399 optList[i].desc);
409 } 400 }
410 fprintf (stderr, "\n --help to list long-options"); 401 rxvt_log ("\n --help to list long-options");
411 break; 402 break;
412 403
413 case 2: /* full resource listing */ 404 case 2: /* full resource listing */
414 fprintf (stderr,
415 " [options] [-e command args]\n\n" 405 rxvt_log (" [options] [-e command args]\n\n"
416 "where resources (long-options) include:\n"); 406 "where resources (long-options) include:\n");
417 407
418 for (i = 0; i < optList_size (); i++) 408 for (i = 0; i < optList_size (); i++)
419 if (optList[i].kw != NULL) 409 if (optList[i].kw != NULL)
420 fprintf (stderr, " %s: %*s%s\n", 410 rxvt_log (" %s: %*s%s\n",
421 optList[i].kw, 411 optList[i].kw,
422 (INDENT - STRLEN (optList[i].kw)), "", /* XXX */ 412 (INDENT - STRLEN (optList[i].kw)), "", /* XXX */
423 (optList_isBool (i) ? "boolean" : optList[i].arg)); 413 (optList_isBool (i) ? "boolean" : optList[i].arg));
424#ifdef KEYSYM_RESOURCE 414#ifdef KEYSYM_RESOURCE
425 fprintf (stderr, " " "keysym.sym" ": %*s%s\n", 415 rxvt_log (" " "keysym.sym" ": %*s%s\n",
426 (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */ 416 (INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */
427 "keysym"); 417 "keysym");
428#endif 418#endif
429 fprintf (stderr, "\n -help to list options"); 419 rxvt_log ("\n -help to list options");
430 break; 420 break;
431 } 421 }
432 fprintf (stderr, "\n\n"); 422
433 exit (EXIT_FAILURE); 423 rxvt_log ("\n\n");
424 rxvt_exit_failure ();
434 /* NOTREACHED */ 425 /* NOTREACHED */
435} 426}
436 427
437/*}}} */ 428/*}}} */
438 429
465 longopt = *opt++; /* long option */ 456 longopt = *opt++; /* long option */
466 } 457 }
467 else 458 else
468 { 459 {
469 bad_option = 1; 460 bad_option = 1;
470 rxvt_print_error ("bad option \"%s\"", opt); 461 rxvt_warn ("\"%s\": malformed option.\n", opt);
471 continue; 462 continue;
472 } 463 }
473 464
474 if (!STRCMP (opt, "help")) 465 if (!STRCMP (opt, "help"))
475 rxvt_usage (longopt ? 2 : 1); 466 rxvt_usage (longopt ? 2 : 1);
532 else 523 else
533#ifdef KEYSYM_RESOURCE 524#ifdef KEYSYM_RESOURCE
534 /* if (!STRNCMP (opt, "keysym.", sizeof ("keysym.") - 1)) */ 525 /* if (!STRNCMP (opt, "keysym.", sizeof ("keysym.") - 1)) */
535 if (rxvt_Str_match (opt, "keysym.")) 526 if (rxvt_Str_match (opt, "keysym."))
536 { 527 {
537 const char *str = argv[++i]; 528 const char *str = argv[++i];
538 529
539 if (str != NULL) 530 if (str != NULL)
540 parse_keysym (opt + sizeof ("keysym.") - 1, str); 531 parse_keysym (opt + sizeof ("keysym.") - 1, str);
541 } 532 }
542 else 533 else
543#endif 534#endif
535 {
544 bad_option = 1; 536 bad_option = 1;
537 rxvt_warn ("\"%s\": unknown or malformed option.\n", opt);
538 }
545 } 539 }
546 540
547 if (bad_option) 541 if (bad_option)
548 rxvt_usage (0); 542 rxvt_usage (0);
549} 543}
559 * quarks will be something like 553 * quarks will be something like
560 * "rxvt" "keysym" "0xFF01" 554 * "rxvt" "keysym" "0xFF01"
561 * value will be a string 555 * value will be a string
562 */ 556 */
563/* ARGSUSED */ 557/* ARGSUSED */
564bool 558int
565rxvt_define_key(XrmDatabase *database __attribute__((unused)), XrmBindingList bindings __attribute__((unused)), XrmQuarkList quarks, XrmRepresentation *type __attribute__((unused)), XrmValue *value, XPointer closure __attribute__((unused))) 559rxvt_define_key (XrmDatabase *database __attribute__((unused)),
560 XrmBindingList bindings __attribute__((unused)),
561 XrmQuarkList quarks,
562 XrmRepresentation *type __attribute__((unused)),
563 XrmValue *value,
564 XPointer closure __attribute__((unused)))
566{ 565{
567 int last; 566 int last;
568 567
569 for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ 568 for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */
570 ; 569 ;
666 * the matching algorithm used for memory-save fake resources 665 * the matching algorithm used for memory-save fake resources
667 */ 666 */
668void 667void
669rxvt_term::get_xdefaults (FILE *stream, const char *name) 668rxvt_term::get_xdefaults (FILE *stream, const char *name)
670{ 669{
671 unsigned int len; 670 unsigned int len;
672 char *str, buffer[256]; 671 char *str, buffer[256];
673 672
674 if (stream == NULL) 673 if (stream == NULL)
675 return; 674 return;
675
676 len = STRLEN (name); 676 len = STRLEN (name);
677 while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL) 677 while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL)
678 { 678 {
679 unsigned int entry, n; 679 unsigned int entry, n;
680 680
689# ifdef KEYSYM_RESOURCE 689# ifdef KEYSYM_RESOURCE
690 if (!parse_keysym (str, NULL)) 690 if (!parse_keysym (str, NULL))
691# endif /* KEYSYM_RESOURCE */ 691# endif /* KEYSYM_RESOURCE */
692 for (entry = 0; entry < optList_size (); entry++) 692 for (entry = 0; entry < optList_size (); entry++)
693 { 693 {
694 const char *kw = optList[entry].kw; 694 const char *kw = optList[entry].kw;
695 695
696 if (kw == NULL) 696 if (kw == NULL)
697 continue; 697 continue;
698
698 n = STRLEN (kw); 699 n = STRLEN (kw);
699 if (str[n] == ':' && rxvt_Str_match (str, kw)) 700 if (str[n] == ':' && rxvt_Str_match (str, kw))
700 { 701 {
701 /* skip `keyword:' */ 702 /* skip `keyword:' */
702 str += (n + 1); 703 str += n + 1;
703 rxvt_Str_trim (str); 704 rxvt_Str_trim (str);
704 n = STRLEN (str); 705 n = STRLEN (str);
705 if (n && rs[optList[entry].doff] == NULL) 706 if (n && rs[optList[entry].doff] == NULL)
706 { 707 {
707 /* not already set */ 708 /* not already set */
708 int s; 709 int s;
709 char *p = (char *)rxvt_malloc ((n + 1) * sizeof (char)); 710 char *p = 0;
710 711
712 for (int o = 0;;)
713 {
714 p = (char *)rxvt_realloc (p, o + n + 1);
711 STRCPY (p, str); 715 MEMCPY (p + o, str, n);
716 o += n;
717 p[o] = 0;
718
719 if (o == 0 || p[o - 1] != '\\') // continuation line
720 break;
721
722 o--; // eat "\"
723
724 if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL)
725 break;
726
727 rxvt_Str_trim (str);
728 n = STRLEN (str);
729 }
730
712 rs[optList[entry].doff] = p; 731 rs[optList[entry].doff] = p;
732 allocated.push_back (p);
733
713 if (optList_isBool (entry)) 734 if (optList_isBool (entry))
714 { 735 {
715 s = STRCASECMP (str, "TRUE") == 0 736 s = STRCASECMP (str, "TRUE") == 0
716 || STRCASECMP (str, "YES") == 0 737 || STRCASECMP (str, "YES") == 0
717 || STRCASECMP (str, "ON") == 0 738 || STRCASECMP (str, "ON") == 0
718 || STRCASECMP (str, "1") == 0; 739 || STRCASECMP (str, "1") == 0;
740
719 if (optList_isReverse (entry)) 741 if (optList_isReverse (entry))
720 s = !s; 742 s = !s;
743
721 if (s) 744 if (s)
722 Options |= (optList[entry].flag); 745 Options |= optList[entry].flag;
723 else 746 else
724 Options &= ~ (optList[entry].flag); 747 Options &= ~optList[entry].flag;
725 } 748 }
726 } 749 }
750
727 break; 751 break;
728 } 752 }
729 } 753 }
730 } 754 }
755
731 rewind (stream); 756 rewind (stream);
732} 757}
733 758
734/*}}} */ 759/*}}} */
735# endif /* ! USE_XGETDEFAULT */ 760# endif /* ! USE_XGETDEFAULT */
746#ifndef NO_RESOURCES 771#ifndef NO_RESOURCES
747 772
748# if defined XAPPLOADDIR 773# if defined XAPPLOADDIR
749# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) 774# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
750 /* Compute the path of the possibly available localized Rxvt file */ 775 /* Compute the path of the possibly available localized Rxvt file */
751 char *localepath = NULL; 776 char *localepath = NULL;
752 777
753 if (locale != NULL) 778 if (locale != NULL)
754 { /* XXX: must limit length of string */ 779 { /* XXX: must limit length of string */
755 localepath = (char *)rxvt_malloc (256); 780 localepath = (char *)rxvt_malloc (256);
756 sprintf (localepath, XAPPLOADDIRLOCALE "/" APL_SUBCLASS, 781 sprintf (localepath, XAPPLOADDIRLOCALE "/" RESCLASS,
757 (int) (258 - sizeof (XAPPLOADDIRLOCALE) - sizeof (APL_SUBCLASS)), 782 (int) (258 - sizeof (XAPPLOADDIRLOCALE) - sizeof (RESCLASS)),
758 locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ 783 locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */
759 } 784 }
760 785
761 { 786 {
762# endif 787# endif
764 789
765# ifdef USE_XGETDEFAULT 790# ifdef USE_XGETDEFAULT
766 /* 791 /*
767 * get resources using the X library function 792 * get resources using the X library function
768 */ 793 */
769 int entry; 794 int entry;
770 795
771# ifdef XrmEnumOneLevel 796# ifdef XrmEnumOneLevel
772 int i; 797 int i;
773 char *displayResource, *xe; 798 char *displayResource, *xe;
774 XrmName name_prefix[3]; 799 XrmName name_prefix[3];
775 XrmClass class_prefix[3]; 800 XrmClass class_prefix[3];
776 XrmDatabase database, rdb1; 801 XrmDatabase database, rdb1;
777 char fname[1024]; 802 char fname[1024];
778 803
779 XrmInitialize (); 804 XrmInitialize ();
780 database = NULL; 805 database = NULL;
781 806
782 /* Get any Xserver defaults */ 807 /* Get any Xserver defaults */
795 820
796 for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++) 821 for (i = 0; i < (sizeof (xnames) / sizeof (xnames[0])); i++)
797 { 822 {
798 sprintf (fname, "%-.*s/%s", sizeof (fname) - STRLEN (xnames[i]) - 2, 823 sprintf (fname, "%-.*s/%s", sizeof (fname) - STRLEN (xnames[i]) - 2,
799 ptr, xnames[i]); 824 ptr, xnames[i]);
800 if ((rdb1 = XrmGetFileDatabase (fname)) != NULL) 825 if ((rdb1 = XrmGetFileDatabase (fname)))
801 { 826 {
802 XrmMergeDatabases (rdb1, &database); 827 XrmMergeDatabases (rdb1, &database);
803# ifndef HAVE_BOTH_XRESOURCE_FILES 828# ifndef HAVE_BOTH_XRESOURCE_FILES
804 break; 829 break;
805# endif 830# endif
817 842
818 /* Add in Rxvt file */ 843 /* Add in Rxvt file */
819# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) 844# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
820 if (localepath == NULL || (rdb1 = XrmGetFileDatabase (localepath)) == NULL) 845 if (localepath == NULL || (rdb1 = XrmGetFileDatabase (localepath)) == NULL)
821# endif 846# endif
822 rdb1 = XrmGetFileDatabase (XAPPLOADDIR "/" APL_SUBCLASS); 847 rdb1 = XrmGetFileDatabase (XAPPLOADDIR "/" RESCLASS);
848
823 if (rdb1 != NULL) 849 if (rdb1 != NULL)
824 XrmMergeDatabases (rdb1, &database); 850 XrmMergeDatabases (rdb1, &database);
825 851
826 /* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */ 852 /* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */
827 if ((xe = (char *)getenv ("XAPPLRESDIR")) != NULL) 853 if ((xe = (char *)getenv ("XAPPLRESDIR")) != NULL)
828 { 854 {
829 sprintf (fname, "%-.*s/" APL_SUBCLASS, sizeof (fname) 855 sprintf (fname, "%-.*s/" RESCLASS, sizeof (fname)
830 - sizeof (APL_SUBCLASS) - 2, xe); 856 - sizeof (RESCLASS) - 2, xe);
831 if ((rdb1 = XrmGetFileDatabase (fname)) != NULL) 857 if ((rdb1 = XrmGetFileDatabase (fname)) != NULL)
832 XrmMergeDatabases (rdb1, &database); 858 XrmMergeDatabases (rdb1, &database);
833 } 859 }
834 860
835 XrmSetDatabase (display, database); 861 XrmSetDatabase (display, database);
849 875
850 p = XGetDefault (display, name, kw); 876 p = XGetDefault (display, name, kw);
851 p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); 877 p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw);
852 if (p == NULL || (p0 && STRCMP (p, p0) == 0)) 878 if (p == NULL || (p0 && STRCMP (p, p0) == 0))
853 { 879 {
854 p = XGetDefault (display, APL_SUBCLASS, kw); 880 p = XGetDefault (display, RESCLASS, kw);
881#ifdef RESFALLBACK
855 if (p == NULL || (p0 && STRCMP (p, p0) == 0)) 882 if (p == NULL || (p0 && STRCMP (p, p0) == 0))
856 p = XGetDefault (display, APL_CLASS, kw); 883 p = XGetDefault (display, RESFALLBACK, kw);
884#endif
857 } 885 }
886
858 if (p == NULL && p0) 887 if (p == NULL && p0)
859 p = p0; 888 p = p0;
889
860 if (p) 890 if (p)
861 { 891 {
862 rs[optList[entry].doff] = p; 892 rs[optList[entry].doff] = p;
863 893
864 if (optList_isBool (entry)) 894 if (optList_isBool (entry))
883# ifdef XrmEnumOneLevel 913# ifdef XrmEnumOneLevel
884# ifdef KEYSYM_RESOURCE 914# ifdef KEYSYM_RESOURCE
885 name_prefix[0] = XrmStringToName (name); 915 name_prefix[0] = XrmStringToName (name);
886 name_prefix[1] = XrmStringToName ("keysym"); 916 name_prefix[1] = XrmStringToName ("keysym");
887 name_prefix[2] = NULLQUARK; 917 name_prefix[2] = NULLQUARK;
888 class_prefix[0] = XrmStringToName (APL_SUBCLASS); 918 class_prefix[0] = XrmStringToName (RESCLASS);
889 class_prefix[1] = XrmStringToName ("Keysym"); 919 class_prefix[1] = XrmStringToName ("Keysym");
890 class_prefix[2] = NULLQUARK; 920 class_prefix[2] = NULLQUARK;
891 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ 921 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
892 XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix, 922 XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix,
893 XrmEnumOneLevel, rxvt_define_key, NULL); 923 XrmEnumOneLevel, rxvt_define_key, NULL);
924# ifdef RESFALLBACK
894 name_prefix[0] = XrmStringToName (APL_CLASS); 925 name_prefix[0] = XrmStringToName (RESFALLBACK);
895 name_prefix[1] = XrmStringToName ("keysym"); 926 name_prefix[1] = XrmStringToName ("keysym");
896 class_prefix[0] = XrmStringToName (APL_CLASS); 927 class_prefix[0] = XrmStringToName (RESFALLBACK);
897 class_prefix[1] = XrmStringToName ("Keysym"); 928 class_prefix[1] = XrmStringToName ("Keysym");
898 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ 929 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
899 XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix, 930 XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix,
900 XrmEnumOneLevel, rxvt_define_key, NULL); 931 XrmEnumOneLevel, rxvt_define_key, NULL);
932# endif
901# endif 933# endif
902# endif 934# endif
903 935
904# else /* USE_XGETDEFAULT */ 936# else /* USE_XGETDEFAULT */
905 /* get resources the hard way, but save lots of memory */ 937 /* get resources the hard way, but save lots of memory */
943 * Also, use a special sub-class so that we can use either or both of 975 * Also, use a special sub-class so that we can use either or both of
944 * "XTerm" and "Rxvt" as class names. 976 * "XTerm" and "Rxvt" as class names.
945 */ 977 */
946 978
947 get_xdefaults (fd, name); 979 get_xdefaults (fd, name);
948 get_xdefaults (fd, APL_SUBCLASS); 980 get_xdefaults (fd, RESCLASS);
981# ifdef RESFALLBACK
982 get_xdefaults (fd, RESFALLBACK);
983# endif
949 984
950# if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR) 985# if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR)
951
952 { 986 {
953 FILE *ad = NULL; 987 FILE *ad = NULL;
954 988
955# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) 989# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
956 if (localepath == NULL || (ad = fopen (localepath, "r")) == NULL) 990 if (localepath == NULL || (ad = fopen (localepath, "r")) == NULL)
957# endif 991# endif
958 ad = fopen (XAPPLOADDIR "/" APL_SUBCLASS, "r"); 992 ad = fopen (XAPPLOADDIR "/" RESCLASS, "r");
959 if (ad != NULL) 993 if (ad != NULL)
960 { 994 {
961 get_xdefaults (ad, APL_SUBCLASS); 995 get_xdefaults (ad, RESCLASS);
962 get_xdefaults (ad, ""); 996 get_xdefaults (ad, "");
963 fclose (ad); 997 fclose (ad);
964 } 998 }
965 } 999 }
966# endif /* XAPPLOADDIR */ 1000# endif /* XAPPLOADDIR */
967 1001
968 get_xdefaults (fd, APL_CLASS);
969 get_xdefaults (fd, ""); /* partial match */ 1002 get_xdefaults (fd, ""); /* partial match */
970 if (fd != NULL) 1003 if (fd != NULL)
971 fclose (fd); 1004 fclose (fd);
972# endif /* USE_XGETDEFAULT */ 1005# endif /* USE_XGETDEFAULT */
973 1006
980 free (localepath); 1013 free (localepath);
981# endif 1014# endif
982# endif 1015# endif
983 1016
984#endif /* NO_RESOURCES */ 1017#endif /* NO_RESOURCES */
985
986 /*
987 * even without resources, at least do this setup for command-line
988 * options and command-line long options
989 */
990
991#if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
992 KeySym sym;
993
994 if (rs[Rs_bigfont_key]
995 && ((sym = XStringToKeysym (rs[Rs_bigfont_key])) != 0))
996 ks_bigfont = sym;
997 if (rs[Rs_smallfont_key]
998 && ((sym = XStringToKeysym (rs[Rs_smallfont_key])) != 0))
999 ks_smallfont = sym;
1000#endif
1001} 1018}
1002 1019
1003/*}}} */ 1020/*}}} */
1004/*----------------------- end-of-file (C source) -----------------------*/ 1021/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines