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.148 by sf-exg, Thu Oct 14 22:08:45 2010 UTC vs.
Revision 1.157 by root, Thu Dec 1 10:50:53 2011 UTC

4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> 6 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
7 * - original version 7 * - original version
8 * 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-2006 Marc Lehmann <pcg@goof.com> 9 * Copyright (c) 2003-2006 Marc Lehmann <schmorp@schmorp.de>
10 * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> 10 * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it>
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or 14 * the Free Software Foundation; either version 2 of the License, or
69 (optList[i].flag == 0) 69 (optList[i].flag == 0)
70#define optList_isBool(i) \ 70#define optList_isBool(i) \
71 (optList[i].flag & Optflag_Boolean) 71 (optList[i].flag & Optflag_Boolean)
72#define optList_isReverse(i) \ 72#define optList_isReverse(i) \
73 (optList[i].flag & Optflag_Reverse) 73 (optList[i].flag & Optflag_Reverse)
74#define optList_size \
75 (sizeof (optList) / sizeof (optList[0]))
76 74
77static const struct 75static const struct
78 { 76 {
79 const uint8_t index; /* Option index */ 77 const uint8_t index; /* Option index */
80 const uint8_t flag; /* Option flag */ 78 const uint8_t flag; /* Option flag */
399 switch (type) 397 switch (type)
400 { 398 {
401 case 0: /* brief listing */ 399 case 0: /* brief listing */
402 rxvt_log (" [-help] [--help]\n"); 400 rxvt_log (" [-help] [--help]\n");
403 401
404 for (col = 1, i = 0; i < optList_size; i++) 402 for (col = 1, i = 0; i < ecb_array_length (optList); i++)
405 if (optList[i].desc != NULL) 403 if (optList[i].desc != NULL)
406 { 404 {
407 int len = 0; 405 int len = 0;
408 406
409 if (optList[i].arg) 407 if (optList[i].arg)
410 len = strlen (optList[i].arg) + 1; 408 len = strlen (optList[i].arg) + 1;
411 assert (optList[i].opt != NULL); 409 assert (optList[i].opt != NULL);
412 len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2: 0); 410 len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2 : 0);
413 col += len; 411 col += len;
414 if (col > 79) 412 if (col > 79)
415 { 413 {
416 /* assume regular width */ 414 /* assume regular width */
417 rxvt_log ("\n"); 415 rxvt_log ("\n");
427 break; 425 break;
428 426
429 case 1: /* full command-line listing */ 427 case 1: /* full command-line listing */
430 rxvt_log (" [options] [-e command args]\n\nwhere options include:\n"); 428 rxvt_log (" [options] [-e command args]\n\nwhere options include:\n");
431 429
432 for (i = 0; i < optList_size; i++) 430 for (i = 0; i < ecb_array_length (optList); i++)
433 if (optList[i].desc != NULL) 431 if (optList[i].desc != NULL)
434 { 432 {
435 assert (optList[i].opt != NULL); 433 assert (optList[i].opt != NULL);
436 rxvt_log (" %s%s %-*s%s%s\n", 434 rxvt_log (" %s%s %-*s%s%s\n",
437 (optList_isBool (i) ? "-/+" : "-"), optList[i].opt, 435 (optList_isBool (i) ? "-/+" : "-"), optList[i].opt,
446 444
447 case 2: /* full resource listing */ 445 case 2: /* full resource listing */
448 rxvt_log (" [options] [-e command args]\n\n" 446 rxvt_log (" [options] [-e command args]\n\n"
449 "where resources (long-options) include:\n"); 447 "where resources (long-options) include:\n");
450 448
451 for (i = 0; i < optList_size; i++) 449 for (i = 0; i < ecb_array_length (optList); i++)
452 if (optList[i].kw != NULL) 450 if (optList[i].kw != NULL)
453 rxvt_log (" %s: %*s%s\n", 451 rxvt_log (" %s: %*s%s\n",
454 optList[i].kw, 452 optList[i].kw,
455 (INDENT - strlen (optList[i].kw)), "", /* XXX */ 453 (INDENT - strlen (optList[i].kw)), "", /* XXX */
456 (optList_isBool (i) ? "boolean" : optList[i].arg)); 454 (optList_isBool (i) ? "boolean" : optList[i].arg));
463 break; 461 break;
464 } 462 }
465 463
466 rxvt_log ("\n\n"); 464 rxvt_log ("\n\n");
467 rxvt_exit_failure (); 465 rxvt_exit_failure ();
468 /* NOTREACHED */
469} 466}
470 467
471/*}}} */ 468/*}}} */
472 469
473/*{{{ get command-line options before getting resources */ 470/*{{{ get command-line options before getting resources */
510 507
511 if (!strcmp (opt, "h")) 508 if (!strcmp (opt, "h"))
512 rxvt_usage (0); 509 rxvt_usage (0);
513 510
514 /* feature: always try to match long-options */ 511 /* feature: always try to match long-options */
515 for (entry = 0; entry < optList_size; entry++) 512 for (entry = 0; entry < ecb_array_length (optList); entry++)
516 if ((optList[entry].kw && !strcmp (opt, optList[entry].kw)) 513 if ((optList[entry].kw && !strcmp (opt, optList[entry].kw))
517 || (!longopt 514 || (!longopt
518 && optList[entry].opt && !strcmp (opt, optList[entry].opt))) 515 && optList[entry].opt && !strcmp (opt, optList[entry].opt)))
519 break; 516 break;
520 517
521 if (entry < optList_size) 518 if (entry < ecb_array_length (optList))
522 { 519 {
523 if (optList_isReverse (entry)) 520 if (optList_isReverse (entry))
524 flag = !flag; 521 flag = !flag;
525 522
526 if (optList_isString (entry)) 523 if (optList_isString (entry))
527 { 524 {
528 /* 525 /*
529 * special cases are handled in main.c:main () to allow 526 * special cases are handled in init_resources () to allow
530 * X resources to set these values before we settle for 527 * X resources to set these values before we settle for
531 * default values 528 * default values
532 */ 529 */
533 530
534 if (optList[entry].doff != -1) 531 if (optList[entry].doff != -1)
587 * Define key from XrmEnumerateDatabase. 584 * Define key from XrmEnumerateDatabase.
588 * quarks will be something like 585 * quarks will be something like
589 * "rxvt" "keysym" "0xFF01" 586 * "rxvt" "keysym" "0xFF01"
590 * value will be a string 587 * value will be a string
591 */ 588 */
592/* ARGSUSED */ 589static int
593int
594rxvt_define_key (XrmDatabase *database UNUSED, 590rxvt_define_key (XrmDatabase *database ecb_unused,
595 XrmBindingList bindings UNUSED, 591 XrmBindingList bindings ecb_unused,
596 XrmQuarkList quarks, 592 XrmQuarkList quarks,
597 XrmRepresentation *type UNUSED, 593 XrmRepresentation *type ecb_unused,
598 XrmValue *value, 594 XrmValue *value,
599 XPointer closure UNUSED) 595 XPointer closure ecb_unused)
600{ 596{
601 int last; 597 int last;
602 598
603 for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ 599 for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */
604 ; 600 ;
667 // parse modifiers 663 // parse modifiers
668 while (str < key) 664 while (str < key)
669 { 665 {
670 unsigned int i; 666 unsigned int i;
671 667
672 for (i=0; i < sizeof (keysym_vocabulary) / sizeof (keysym_vocabulary_t); ++i) 668 for (i = 0; i < ecb_array_length (keysym_vocabulary); ++i)
673 { 669 {
674 if (strncmp (str, keysym_vocabulary [i].name, keysym_vocabulary [i].len) == 0) 670 if (strncmp (str, keysym_vocabulary [i].name, keysym_vocabulary [i].len) == 0)
675 { 671 {
676 state |= keysym_vocabulary[i].value; 672 state |= keysym_vocabulary[i].value;
677 str += keysym_vocabulary[i].len; 673 str += keysym_vocabulary[i].len;
678 break; 674 break;
679 } 675 }
680 } 676 }
681 677
682 if (i >= sizeof (keysym_vocabulary) / sizeof (keysym_vocabulary_t)) 678 if (i >= ecb_array_length (keysym_vocabulary))
683 return -1; 679 return -1;
684 680
685 if (*str == '-') 681 if (*str == '-')
686 ++str; 682 ++str;
687 } 683 }
747 XrmMergeDatabases (option_db, &database); 743 XrmMergeDatabases (option_db, &database);
748 option_db = NULL; 744 option_db = NULL;
749 /* 745 /*
750 * Query resources for options that affect us 746 * Query resources for options that affect us
751 */ 747 */
752 for (int entry = 0; entry < optList_size; entry++) 748 for (int entry = 0; entry < ecb_array_length (optList); entry++)
753 { 749 {
754 int s; 750 int s;
755 const char *kw = optList[entry].kw; 751 const char *kw = optList[entry].kw;
756 752
757 if (kw == NULL || rs[optList[entry].doff] != NULL) 753 if (kw == NULL || rs[optList[entry].doff] != NULL)
795 class_prefix[2] = NULLQUARK; 791 class_prefix[2] = NULLQUARK;
796 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ 792 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
797 XrmEnumerateDatabase (database, name_prefix, class_prefix, 793 XrmEnumerateDatabase (database, name_prefix, class_prefix,
798 XrmEnumOneLevel, rxvt_define_key, NULL); 794 XrmEnumOneLevel, rxvt_define_key, NULL);
799# ifdef RESFALLBACK 795# ifdef RESFALLBACK
800 name_prefix[0] = XrmStringToName (RESFALLBACK);
801 name_prefix[1] = XrmStringToName ("keysym");
802 class_prefix[0] = XrmStringToName (RESFALLBACK); 796 name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK);
803 class_prefix[1] = XrmStringToName ("Keysym");
804 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ 797 /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */
805 XrmEnumerateDatabase (database, name_prefix, class_prefix, 798 XrmEnumerateDatabase (database, name_prefix, class_prefix,
806 XrmEnumOneLevel, rxvt_define_key, NULL); 799 XrmEnumOneLevel, rxvt_define_key, NULL);
807# endif 800# endif
808# endif 801# endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines