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.1 by pcg, Mon Nov 24 17:28:08 2003 UTC vs.
Revision 1.7 by pcg, Fri Jan 16 22:26:18 2004 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: xdefaults.c 2 * File: xdefaults.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: xdefaults.C,v 1.1 2003/11/24 17:28:08 pcg Exp $ 4 * $Id: xdefaults.C,v 1.7 2004/01/16 22:26:18 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>
141#endif 141#endif
142#ifdef CURSOR_BLINK 142#ifdef CURSOR_BLINK
143 BOOL(Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"), 143 BOOL(Rs_cursorBlink, "cursorBlink", "bc", Opt_cursorBlink, "blinking cursor"),
144#endif 144#endif
145#ifdef POINTER_BLANK 145#ifdef POINTER_BLANK
146 BOOL(Rs_pointerBlank, "pointerBlank", NULL, Opt_pointerBlank, NULL), 146 BOOL(Rs_pointerBlank, "pointerBlank", "pb", Opt_pointerBlank, "switch off pointer after delay"),
147#endif 147#endif
148 STRG(Rs_color + Color_bg, "background", "bg", "color", "background color"), 148 STRG(Rs_color + Color_bg, "background", "bg", "color", "background color"),
149 STRG(Rs_color + Color_fg, "foreground", "fg", "color", "foreground color"), 149 STRG(Rs_color + Color_fg, "foreground", "fg", "color", "foreground color"),
150 RSTRG(Rs_color + minCOLOR + 0, "color0", "color"), 150 RSTRG(Rs_color + minCOLOR + 0, "color0", "color"),
151 RSTRG(Rs_color + minCOLOR + 1, "color1", "color"), 151 RSTRG(Rs_color + minCOLOR + 1, "color1", "color"),
185 "background pixmap"), 185 "background pixmap"),
186#endif /* XPM_BACKGROUND */ 186#endif /* XPM_BACKGROUND */
187#if (MENUBAR_MAX) 187#if (MENUBAR_MAX)
188 RSTRG(Rs_menu, "menu", "name[;tag]"), 188 RSTRG(Rs_menu, "menu", "name[;tag]"),
189#endif 189#endif
190#ifndef NO_BOLDFONT
191 STRG(Rs_boldFont, "boldFont", "fb", "fontname", "bold text font"),
192#endif
193 STRG(Rs_font + 0, "font", "fn", "fontname", "normal text font"), 190 STRG(Rs_font, "font", "fn", "fontname", "normal text font"),
194/* fonts: command-line option = resource name */ 191/* fonts: command-line option = resource name */
195#ifdef MULTICHAR_SET
196 STRG(Rs_multichar_encoding, "multichar_encoding", "km", "mode",
197 "multichar encoding; mode = eucj|sjis|big5|gb|kr|noenc"),
198#endif /* MULTICHAR_SET */
199#ifdef USE_XIM 192#ifdef USE_XIM
200 STRG(Rs_inputMethod, "inputMethod", "im", "name", "name of input method"), 193 STRG(Rs_inputMethod, "inputMethod", "im", "name", "name of input method"),
201 STRG(Rs_preeditType, "preeditType", "pt", "style", 194 STRG(Rs_preeditType, "preeditType", "pt", "style",
202 "input style: style = OverTheSpot|OffTheSpot|Root"), 195 "input style: style = OverTheSpot|OffTheSpot|Root"),
196#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
197 STRG(Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"),
198#endif
203#endif /* USE_XIM */ 199#endif /* USE_XIM */
204#ifdef GREEK_SUPPORT 200#ifdef GREEK_SUPPORT
205 STRG(Rs_greek_keyboard, "greek_keyboard", "grk", "mode", 201 STRG(Rs_greek_keyboard, "greek_keyboard", "grk", "mode",
206 "greek keyboard mapping; mode = iso | ibm"), 202 "greek keyboard mapping; mode = iso | ibm"),
207 RSTRG(Rs_greektoggle_key, "greektoggle_key", "keysym"), 203 RSTRG(Rs_greektoggle_key, "greektoggle_key", "keysym"),
500#endif 496#endif
501 if (flag == On && str && (optList[entry].doff != -1)) { 497 if (flag == On && str && (optList[entry].doff != -1)) {
502#ifdef DEBUG_RESOURCES 498#ifdef DEBUG_RESOURCES
503 fprintf(stderr, "\"%s\"\n", str); 499 fprintf(stderr, "\"%s\"\n", str);
504#endif 500#endif
505 R->h->rs[optList[entry].doff] = str; 501 R->rs[optList[entry].doff] = str;
506 /* 502 /*
507 * special cases are handled in main.c:main() to allow 503 * special cases are handled in main.c:main() to allow
508 * X resources to set these values before we settle for 504 * X resources to set these values before we settle for
509 * default values 505 * default values
510 */ 506 */
522 R->Options |= (optList[entry].flag); 518 R->Options |= (optList[entry].flag);
523 else 519 else
524 R->Options &= ~(optList[entry].flag); 520 R->Options &= ~(optList[entry].flag);
525 521
526 if (optList[entry].doff != -1) 522 if (optList[entry].doff != -1)
527 R->h->rs[optList[entry].doff] = flag; 523 R->rs[optList[entry].doff] = flag;
528 } 524 }
529 } else 525 } else
530#ifdef KEYSYM_RESOURCE 526#ifdef KEYSYM_RESOURCE
531 /* if (!STRNCMP(opt, "keysym.", sizeof("keysym.") - 1)) */ 527 /* if (!STRNCMP(opt, "keysym.", sizeof("keysym.") - 1)) */
532 if (rxvt_Str_match(opt, "keysym.")) { 528 if (rxvt_Str_match(opt, "keysym.")) {
534 530
535 if (str != NULL) 531 if (str != NULL)
536 rxvt_parse_keysym(aR_ opt + sizeof("keysym.") - 1, str); 532 rxvt_parse_keysym(aR_ opt + sizeof("keysym.") - 1, str);
537 } else 533 } else
538#endif 534#endif
539 ; 535 bad_option = 1;
540 } 536 }
541 537
542 if (bad_option) 538 if (bad_option)
543 rxvt_usage(0); 539 rxvt_usage(0);
544} 540}
624 } 620 }
625 621
626 if (sym < 0xFF00 || sym > 0xFFFF) /* we only do extended keys */ 622 if (sym < 0xFF00 || sym > 0xFFFF) /* we only do extended keys */
627 return -1; 623 return -1;
628 sym &= 0xFF; 624 sym &= 0xFF;
629 if (R->h->Keysym_map[sym] != NULL) /* already set ? */ 625 if (R->Keysym_map[sym] != NULL) /* already set ? */
630 return -1; 626 return -1;
631 627
632 if (newarg == NULL) { 628 if (newarg == NULL) {
633 STRNCPY(newargstr, arg, NEWARGLIM - 1); 629 STRNCPY(newargstr, arg, NEWARGLIM - 1);
634 newargstr[NEWARGLIM - 1] = '\0'; 630 newargstr[NEWARGLIM - 1] = '\0';
640 MIN_IT(n, 255); 636 MIN_IT(n, 255);
641 key_string = (char *)rxvt_malloc((n + 1) * sizeof(char)); 637 key_string = (char *)rxvt_malloc((n + 1) * sizeof(char));
642 638
643 key_string[0] = n; 639 key_string[0] = n;
644 STRNCPY(key_string + 1, newarg, n); 640 STRNCPY(key_string + 1, newarg, n);
645 R->h->Keysym_map[sym] = (unsigned char *)key_string; 641 R->Keysym_map[sym] = (unsigned char *)key_string;
646 642
647 return 1; 643 return 1;
648} 644}
649 645
650# endif /* KEYSYM_RESOURCE */ 646# endif /* KEYSYM_RESOURCE */
681 for (entry = 0; entry < optList_size(); entry++) { 677 for (entry = 0; entry < optList_size(); entry++) {
682 const char *kw = optList[entry].kw; 678 const char *kw = optList[entry].kw;
683 679
684 if (kw == NULL) 680 if (kw == NULL)
685 continue; 681 continue;
686 n = STRLEN(kw); 682 n = STRLEN (kw);
687 if (str[n] == ':' && rxvt_Str_match(str, kw)) { 683 if (str[n] == ':' && rxvt_Str_match(str, kw)) {
688 /* skip `keyword:' */ 684 /* skip `keyword:' */
689 str += (n + 1); 685 str += (n + 1);
690 rxvt_Str_trim(str); 686 rxvt_Str_trim(str);
691 n = STRLEN(str); 687 n = STRLEN(str);
692 if (n && R->h->rs[optList[entry].doff] == NULL) { 688 if (n && R->rs[optList[entry].doff] == NULL) {
693 /* not already set */ 689 /* not already set */
694 int s; 690 int s;
695 char *p = (char *)rxvt_malloc((n + 1) * sizeof(char)); 691 char *p = (char *)rxvt_malloc((n + 1) * sizeof(char));
696 692
697 STRCPY(p, str); 693 STRCPY(p, str);
698 R->h->rs[optList[entry].doff] = p; 694 R->rs[optList[entry].doff] = p;
699 if (optList_isBool(entry)) { 695 if (optList_isBool(entry)) {
700 s = STRCASECMP(str, "TRUE") == 0 696 s = STRCASECMP(str, "TRUE") == 0
701 || STRCASECMP(str, "YES") == 0 697 || STRCASECMP(str, "YES") == 0
702 || STRCASECMP(str, "ON") == 0 698 || STRCASECMP(str, "ON") == 0
703 || STRCASECMP(str, "1") == 0; 699 || STRCASECMP(str, "1") == 0;
734# if defined XAPPLOADDIR 730# if defined XAPPLOADDIR
735# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) 731# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
736 /* Compute the path of the possibly available localized Rxvt file */ 732 /* Compute the path of the possibly available localized Rxvt file */
737 char *localepath = NULL; 733 char *localepath = NULL;
738 734
739 if (R->h->locale != NULL) { /* XXX: must limit length of string */ 735 if (R->locale != NULL) { /* XXX: must limit length of string */
740 localepath = (char *)rxvt_malloc(256); 736 localepath = (char *)rxvt_malloc(256);
741 sprintf(localepath, XAPPLOADDIRLOCALE "/" APL_SUBCLASS, 737 sprintf(localepath, XAPPLOADDIRLOCALE "/" APL_SUBCLASS,
742 (int)(258 - sizeof(XAPPLOADDIRLOCALE) - sizeof(APL_SUBCLASS)), 738 (int)(258 - sizeof(XAPPLOADDIRLOCALE) - sizeof(APL_SUBCLASS)),
743 R->h->locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ 739 R->locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */
744 } 740 }
745 741
746 { 742 {
747# endif 743# endif
748# endif 744# endif
822 for (entry = 0; entry < optList_size(); entry++) { 818 for (entry = 0; entry < optList_size(); entry++) {
823 int s; 819 int s;
824 char *p, *p0; 820 char *p, *p0;
825 const char *kw = optList[entry].kw; 821 const char *kw = optList[entry].kw;
826 822
827 if (kw == NULL || R->h->rs[optList[entry].doff] != NULL) 823 if (kw == NULL || R->rs[optList[entry].doff] != NULL)
828 continue; /* previously set */ 824 continue; /* previously set */
829 825
830 p = XGetDefault(display, name, kw); 826 p = XGetDefault(display, name, kw);
831 p0 = XGetDefault(display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); 827 p0 = XGetDefault(display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw);
832 if (p == NULL || (p0 && STRCMP(p, p0) == 0)) { 828 if (p == NULL || (p0 && STRCMP(p, p0) == 0)) {
835 p = XGetDefault(display, APL_CLASS, kw); 831 p = XGetDefault(display, APL_CLASS, kw);
836 } 832 }
837 if (p == NULL && p0) 833 if (p == NULL && p0)
838 p = p0; 834 p = p0;
839 if (p) { 835 if (p) {
840 R->h->rs[optList[entry].doff] = p; 836 R->rs[optList[entry].doff] = p;
841 837
842 if (optList_isBool(entry)) { 838 if (optList_isBool(entry)) {
843 s = STRCASECMP(p, "TRUE") == 0 839 s = STRCASECMP(p, "TRUE") == 0
844 || STRCASECMP(p, "YES") == 0 840 || STRCASECMP(p, "YES") == 0
845 || STRCASECMP(p, "ON") == 0 841 || STRCASECMP(p, "ON") == 0
958/* 954/*
959 * even without resources, at least do this setup for command-line 955 * even without resources, at least do this setup for command-line
960 * options and command-line long options 956 * options and command-line long options
961 */ 957 */
962#ifdef MULTICHAR_SET 958#ifdef MULTICHAR_SET
963 rxvt_set_multichar_encoding(aR_ R->h->rs[Rs_multichar_encoding]); 959 rxvt_set_multichar_encoding(aR_ R->rs[Rs_multichar_encoding]);
964#endif 960#endif
965#ifdef GREEK_SUPPORT 961#ifdef GREEK_SUPPORT
966/* this could be a function in grkelot.c */ 962/* this could be a function in grkelot.c */
967/* void set_greek_keyboard (const char * str); */ 963/* void set_greek_keyboard (const char * str); */
968 if (R->h->rs[Rs_greek_keyboard]) { 964 if (R->rs[Rs_greek_keyboard]) {
969 if (!STRCMP(R->h->rs[Rs_greek_keyboard], "iso")) 965 if (!STRCMP(R->rs[Rs_greek_keyboard], "iso"))
970 greek_setmode(GREEK_ELOT928); /* former -grk9 */ 966 greek_setmode(GREEK_ELOT928); /* former -grk9 */
971 else if (!STRCMP(R->h->rs[Rs_greek_keyboard], "ibm")) 967 else if (!STRCMP(R->rs[Rs_greek_keyboard], "ibm"))
972 greek_setmode(GREEK_IBM437); /* former -grk4 */ 968 greek_setmode(GREEK_IBM437); /* former -grk4 */
973 } 969 }
974 { 970 {
975 KeySym sym; 971 KeySym sym;
976 972
977 if (R->h->rs[Rs_greektoggle_key] 973 if (R->rs[Rs_greektoggle_key]
978 && ((sym = XStringToKeysym(R->h->rs[Rs_greektoggle_key])) != 0)) 974 && ((sym = XStringToKeysym(R->rs[Rs_greektoggle_key])) != 0))
979 R->h->ks_greekmodeswith = sym; 975 R->ks_greekmodeswith = sym;
980 } 976 }
981#endif /* GREEK_SUPPORT */ 977#endif /* GREEK_SUPPORT */
982 978
983#if defined (HOTKEY_CTRL) || defined (HOTKEY_META) 979#if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
984 { 980 {
985 KeySym sym; 981 KeySym sym;
986 982
987 if (R->h->rs[Rs_bigfont_key] 983 if (R->rs[Rs_bigfont_key]
988 && ((sym = XStringToKeysym(R->h->rs[Rs_bigfont_key])) != 0)) 984 && ((sym = XStringToKeysym(R->rs[Rs_bigfont_key])) != 0))
989 R->h->ks_bigfont = sym; 985 R->ks_bigfont = sym;
990 if (R->h->rs[Rs_smallfont_key] 986 if (R->rs[Rs_smallfont_key]
991 && ((sym = XStringToKeysym(R->h->rs[Rs_smallfont_key])) != 0)) 987 && ((sym = XStringToKeysym(R->rs[Rs_smallfont_key])) != 0))
992 R->h->ks_smallfont = sym; 988 R->ks_smallfont = sym;
993 } 989 }
994#endif 990#endif
995} 991}
996 992
997/*}}} */ 993/*}}} */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines