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.2 by pcg, Mon Nov 24 17:31:28 2003 UTC vs.
Revision 1.5 by pcg, Thu Dec 18 00:29:29 2003 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: xdefaults.c 2 * File: xdefaults.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: xdefaults.C,v 1.2 2003/11/24 17:31:28 pcg Exp $ 4 * $Id: xdefaults.C,v 1.5 2003/12/18 00:29:29 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>
198#endif /* MULTICHAR_SET */ 198#endif /* MULTICHAR_SET */
199#ifdef USE_XIM 199#ifdef USE_XIM
200 STRG(Rs_inputMethod, "inputMethod", "im", "name", "name of input method"), 200 STRG(Rs_inputMethod, "inputMethod", "im", "name", "name of input method"),
201 STRG(Rs_preeditType, "preeditType", "pt", "style", 201 STRG(Rs_preeditType, "preeditType", "pt", "style",
202 "input style: style = OverTheSpot|OffTheSpot|Root"), 202 "input style: style = OverTheSpot|OffTheSpot|Root"),
203#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
204 STRG(Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"),
205#endif
203#endif /* USE_XIM */ 206#endif /* USE_XIM */
204#ifdef GREEK_SUPPORT 207#ifdef GREEK_SUPPORT
205 STRG(Rs_greek_keyboard, "greek_keyboard", "grk", "mode", 208 STRG(Rs_greek_keyboard, "greek_keyboard", "grk", "mode",
206 "greek keyboard mapping; mode = iso | ibm"), 209 "greek keyboard mapping; mode = iso | ibm"),
207 RSTRG(Rs_greektoggle_key, "greektoggle_key", "keysym"), 210 RSTRG(Rs_greektoggle_key, "greektoggle_key", "keysym"),
500#endif 503#endif
501 if (flag == On && str && (optList[entry].doff != -1)) { 504 if (flag == On && str && (optList[entry].doff != -1)) {
502#ifdef DEBUG_RESOURCES 505#ifdef DEBUG_RESOURCES
503 fprintf(stderr, "\"%s\"\n", str); 506 fprintf(stderr, "\"%s\"\n", str);
504#endif 507#endif
505 R->h->rs[optList[entry].doff] = str; 508 R->rs[optList[entry].doff] = str;
506 /* 509 /*
507 * special cases are handled in main.c:main() to allow 510 * special cases are handled in main.c:main() to allow
508 * X resources to set these values before we settle for 511 * X resources to set these values before we settle for
509 * default values 512 * default values
510 */ 513 */
522 R->Options |= (optList[entry].flag); 525 R->Options |= (optList[entry].flag);
523 else 526 else
524 R->Options &= ~(optList[entry].flag); 527 R->Options &= ~(optList[entry].flag);
525 528
526 if (optList[entry].doff != -1) 529 if (optList[entry].doff != -1)
527 R->h->rs[optList[entry].doff] = flag; 530 R->rs[optList[entry].doff] = flag;
528 } 531 }
529 } else 532 } else
530#ifdef KEYSYM_RESOURCE 533#ifdef KEYSYM_RESOURCE
531 /* if (!STRNCMP(opt, "keysym.", sizeof("keysym.") - 1)) */ 534 /* if (!STRNCMP(opt, "keysym.", sizeof("keysym.") - 1)) */
532 if (rxvt_Str_match(opt, "keysym.")) { 535 if (rxvt_Str_match(opt, "keysym.")) {
624 } 627 }
625 628
626 if (sym < 0xFF00 || sym > 0xFFFF) /* we only do extended keys */ 629 if (sym < 0xFF00 || sym > 0xFFFF) /* we only do extended keys */
627 return -1; 630 return -1;
628 sym &= 0xFF; 631 sym &= 0xFF;
629 if (R->h->Keysym_map[sym] != NULL) /* already set ? */ 632 if (R->Keysym_map[sym] != NULL) /* already set ? */
630 return -1; 633 return -1;
631 634
632 if (newarg == NULL) { 635 if (newarg == NULL) {
633 STRNCPY(newargstr, arg, NEWARGLIM - 1); 636 STRNCPY(newargstr, arg, NEWARGLIM - 1);
634 newargstr[NEWARGLIM - 1] = '\0'; 637 newargstr[NEWARGLIM - 1] = '\0';
640 MIN_IT(n, 255); 643 MIN_IT(n, 255);
641 key_string = (char *)rxvt_malloc((n + 1) * sizeof(char)); 644 key_string = (char *)rxvt_malloc((n + 1) * sizeof(char));
642 645
643 key_string[0] = n; 646 key_string[0] = n;
644 STRNCPY(key_string + 1, newarg, n); 647 STRNCPY(key_string + 1, newarg, n);
645 R->h->Keysym_map[sym] = (unsigned char *)key_string; 648 R->Keysym_map[sym] = (unsigned char *)key_string;
646 649
647 return 1; 650 return 1;
648} 651}
649 652
650# endif /* KEYSYM_RESOURCE */ 653# endif /* KEYSYM_RESOURCE */
681 for (entry = 0; entry < optList_size(); entry++) { 684 for (entry = 0; entry < optList_size(); entry++) {
682 const char *kw = optList[entry].kw; 685 const char *kw = optList[entry].kw;
683 686
684 if (kw == NULL) 687 if (kw == NULL)
685 continue; 688 continue;
686 n = STRLEN(kw); 689 n = STRLEN (kw);
687 if (str[n] == ':' && rxvt_Str_match(str, kw)) { 690 if (str[n] == ':' && rxvt_Str_match(str, kw)) {
688 /* skip `keyword:' */ 691 /* skip `keyword:' */
689 str += (n + 1); 692 str += (n + 1);
690 rxvt_Str_trim(str); 693 rxvt_Str_trim(str);
691 n = STRLEN(str); 694 n = STRLEN(str);
692 if (n && R->h->rs[optList[entry].doff] == NULL) { 695 if (n && R->rs[optList[entry].doff] == NULL) {
693 /* not already set */ 696 /* not already set */
694 int s; 697 int s;
695 char *p = (char *)rxvt_malloc((n + 1) * sizeof(char)); 698 char *p = (char *)rxvt_malloc((n + 1) * sizeof(char));
696 699
697 STRCPY(p, str); 700 STRCPY(p, str);
698 R->h->rs[optList[entry].doff] = p; 701 R->rs[optList[entry].doff] = p;
699 if (optList_isBool(entry)) { 702 if (optList_isBool(entry)) {
700 s = STRCASECMP(str, "TRUE") == 0 703 s = STRCASECMP(str, "TRUE") == 0
701 || STRCASECMP(str, "YES") == 0 704 || STRCASECMP(str, "YES") == 0
702 || STRCASECMP(str, "ON") == 0 705 || STRCASECMP(str, "ON") == 0
703 || STRCASECMP(str, "1") == 0; 706 || STRCASECMP(str, "1") == 0;
734# if defined XAPPLOADDIR 737# if defined XAPPLOADDIR
735# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) 738# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
736 /* Compute the path of the possibly available localized Rxvt file */ 739 /* Compute the path of the possibly available localized Rxvt file */
737 char *localepath = NULL; 740 char *localepath = NULL;
738 741
739 if (R->h->locale != NULL) { /* XXX: must limit length of string */ 742 if (R->locale != NULL) { /* XXX: must limit length of string */
740 localepath = (char *)rxvt_malloc(256); 743 localepath = (char *)rxvt_malloc(256);
741 sprintf(localepath, XAPPLOADDIRLOCALE "/" APL_SUBCLASS, 744 sprintf(localepath, XAPPLOADDIRLOCALE "/" APL_SUBCLASS,
742 (int)(258 - sizeof(XAPPLOADDIRLOCALE) - sizeof(APL_SUBCLASS)), 745 (int)(258 - sizeof(XAPPLOADDIRLOCALE) - sizeof(APL_SUBCLASS)),
743 R->h->locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ 746 R->locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */
744 } 747 }
745 748
746 { 749 {
747# endif 750# endif
748# endif 751# endif
822 for (entry = 0; entry < optList_size(); entry++) { 825 for (entry = 0; entry < optList_size(); entry++) {
823 int s; 826 int s;
824 char *p, *p0; 827 char *p, *p0;
825 const char *kw = optList[entry].kw; 828 const char *kw = optList[entry].kw;
826 829
827 if (kw == NULL || R->h->rs[optList[entry].doff] != NULL) 830 if (kw == NULL || R->rs[optList[entry].doff] != NULL)
828 continue; /* previously set */ 831 continue; /* previously set */
829 832
830 p = XGetDefault(display, name, kw); 833 p = XGetDefault(display, name, kw);
831 p0 = XGetDefault(display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); 834 p0 = XGetDefault(display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw);
832 if (p == NULL || (p0 && STRCMP(p, p0) == 0)) { 835 if (p == NULL || (p0 && STRCMP(p, p0) == 0)) {
835 p = XGetDefault(display, APL_CLASS, kw); 838 p = XGetDefault(display, APL_CLASS, kw);
836 } 839 }
837 if (p == NULL && p0) 840 if (p == NULL && p0)
838 p = p0; 841 p = p0;
839 if (p) { 842 if (p) {
840 R->h->rs[optList[entry].doff] = p; 843 R->rs[optList[entry].doff] = p;
841 844
842 if (optList_isBool(entry)) { 845 if (optList_isBool(entry)) {
843 s = STRCASECMP(p, "TRUE") == 0 846 s = STRCASECMP(p, "TRUE") == 0
844 || STRCASECMP(p, "YES") == 0 847 || STRCASECMP(p, "YES") == 0
845 || STRCASECMP(p, "ON") == 0 848 || STRCASECMP(p, "ON") == 0
958/* 961/*
959 * even without resources, at least do this setup for command-line 962 * even without resources, at least do this setup for command-line
960 * options and command-line long options 963 * options and command-line long options
961 */ 964 */
962#ifdef MULTICHAR_SET 965#ifdef MULTICHAR_SET
963 rxvt_set_multichar_encoding(aR_ R->h->rs[Rs_multichar_encoding]); 966 rxvt_set_multichar_encoding(aR_ R->rs[Rs_multichar_encoding]);
964#endif 967#endif
965#ifdef GREEK_SUPPORT 968#ifdef GREEK_SUPPORT
966/* this could be a function in grkelot.c */ 969/* this could be a function in grkelot.c */
967/* void set_greek_keyboard (const char * str); */ 970/* void set_greek_keyboard (const char * str); */
968 if (R->h->rs[Rs_greek_keyboard]) { 971 if (R->rs[Rs_greek_keyboard]) {
969 if (!STRCMP(R->h->rs[Rs_greek_keyboard], "iso")) 972 if (!STRCMP(R->rs[Rs_greek_keyboard], "iso"))
970 greek_setmode(GREEK_ELOT928); /* former -grk9 */ 973 greek_setmode(GREEK_ELOT928); /* former -grk9 */
971 else if (!STRCMP(R->h->rs[Rs_greek_keyboard], "ibm")) 974 else if (!STRCMP(R->rs[Rs_greek_keyboard], "ibm"))
972 greek_setmode(GREEK_IBM437); /* former -grk4 */ 975 greek_setmode(GREEK_IBM437); /* former -grk4 */
973 } 976 }
974 { 977 {
975 KeySym sym; 978 KeySym sym;
976 979
977 if (R->h->rs[Rs_greektoggle_key] 980 if (R->rs[Rs_greektoggle_key]
978 && ((sym = XStringToKeysym(R->h->rs[Rs_greektoggle_key])) != 0)) 981 && ((sym = XStringToKeysym(R->rs[Rs_greektoggle_key])) != 0))
979 R->h->ks_greekmodeswith = sym; 982 R->ks_greekmodeswith = sym;
980 } 983 }
981#endif /* GREEK_SUPPORT */ 984#endif /* GREEK_SUPPORT */
982 985
983#if defined (HOTKEY_CTRL) || defined (HOTKEY_META) 986#if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
984 { 987 {
985 KeySym sym; 988 KeySym sym;
986 989
987 if (R->h->rs[Rs_bigfont_key] 990 if (R->rs[Rs_bigfont_key]
988 && ((sym = XStringToKeysym(R->h->rs[Rs_bigfont_key])) != 0)) 991 && ((sym = XStringToKeysym(R->rs[Rs_bigfont_key])) != 0))
989 R->h->ks_bigfont = sym; 992 R->ks_bigfont = sym;
990 if (R->h->rs[Rs_smallfont_key] 993 if (R->rs[Rs_smallfont_key]
991 && ((sym = XStringToKeysym(R->h->rs[Rs_smallfont_key])) != 0)) 994 && ((sym = XStringToKeysym(R->rs[Rs_smallfont_key])) != 0))
992 R->h->ks_smallfont = sym; 995 R->ks_smallfont = sym;
993 } 996 }
994#endif 997#endif
995} 998}
996 999
997/*}}} */ 1000/*}}} */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines