1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: xdefaults.c |
2 | * File: xdefaults.c |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * $Id: xdefaults.C,v 1.11 2004/02/13 12:16:21 pcg Exp $ |
4 | * $Id: xdefaults.C,v 1.15 2004/03/03 04:07:52 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 |
… | |
… | |
197 | "input style: style = OverTheSpot|OffTheSpot|Root"), |
193 | "input style: style = OverTheSpot|OffTheSpot|Root"), |
198 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
194 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
199 | STRG (Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"), |
195 | STRG (Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"), |
200 | #endif |
196 | #endif |
201 | #endif /* USE_XIM */ |
197 | #endif /* USE_XIM */ |
202 | #ifdef GREEK_SUPPORT |
|
|
203 | STRG (Rs_greek_keyboard, "greek_keyboard", "grk", "mode", |
|
|
204 | "greek keyboard mapping; mode = iso | ibm"), |
|
|
205 | RSTRG (Rs_greektoggle_key, "greektoggle_key", "keysym"), |
|
|
206 | #endif |
|
|
207 | STRG (Rs_name, NULL, "name", "string", |
198 | STRG (Rs_name, NULL, "name", "string", |
208 | "client instance, icon, and title strings"), |
199 | "client instance, icon, and title strings"), |
209 | STRG (Rs_title, "title", "title", "string", "title name for window"), |
200 | STRG (Rs_title, "title", "title", "string", "title name for window"), |
210 | STRG (Rs_title, NULL, "T", NULL, NULL), /* short form */ |
201 | STRG (Rs_title, NULL, "T", NULL, NULL), /* short form */ |
211 | STRG (Rs_iconName, "iconName", "n", "string", "icon name for window"), |
202 | STRG (Rs_iconName, "iconName", "n", "string", "icon name for window"), |
… | |
… | |
299 | "24bit," |
290 | "24bit," |
300 | #endif |
291 | #endif |
301 | #if defined(USE_XIM) |
292 | #if defined(USE_XIM) |
302 | "XIM," |
293 | "XIM," |
303 | #endif |
294 | #endif |
304 | #if defined(MULTICHAR_SET) |
|
|
305 | "multichar_languages," |
|
|
306 | #endif |
|
|
307 | "scrollbars=" |
295 | "scrollbars=" |
308 | #if !defined(HAVE_SCROLLBARS) |
296 | #if !defined(HAVE_SCROLLBARS) |
309 | "NONE" |
297 | "NONE" |
310 | #else |
298 | #else |
|
|
299 | # if defined(PLAIN_SCROLLBAR) |
|
|
300 | "plain" |
|
|
301 | # if defined(RXVT_SCROLLBAR) || defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) |
|
|
302 | "+" |
|
|
303 | # endif |
|
|
304 | # endif |
311 | # if defined(RXVT_SCROLLBAR) |
305 | # if defined(RXVT_SCROLLBAR) |
312 | "rxvt" |
306 | "rxvt" |
313 | # if defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) |
307 | # if defined(NEXT_SCROLLBAR) || defined(XTERM_SCROLLBAR) |
314 | "+" |
308 | "+" |
315 | # endif |
309 | # endif |
… | |
… | |
323 | # if defined(XTERM_SCROLLBAR) |
317 | # if defined(XTERM_SCROLLBAR) |
324 | "xterm" |
318 | "xterm" |
325 | # endif |
319 | # endif |
326 | #endif |
320 | #endif |
327 | "," |
321 | "," |
328 | #if defined(GREEK_SUPPORT) |
|
|
329 | "Greek," |
|
|
330 | #endif |
|
|
331 | #if defined(RXVT_GRAPHICS) |
|
|
332 | "graphics," |
|
|
333 | #endif |
|
|
334 | #if defined(NO_BACKSPACE_KEY) |
322 | #if defined(NO_BACKSPACE_KEY) |
335 | "no_backspace," |
323 | "no_backspace," |
336 | #endif |
324 | #endif |
337 | #if defined(NO_DELETE_KEY) |
325 | #if defined(NO_DELETE_KEY) |
338 | "no_delete," |
326 | "no_delete," |
… | |
… | |
363 | { |
351 | { |
364 | unsigned int i, col; |
352 | unsigned int i, col; |
365 | |
353 | |
366 | write (STDERR_FILENO, releasestring, sizeof (releasestring) - 1); |
354 | write (STDERR_FILENO, releasestring, sizeof (releasestring) - 1); |
367 | write (STDERR_FILENO, optionsstring, sizeof (optionsstring) - 1); |
355 | write (STDERR_FILENO, optionsstring, sizeof (optionsstring) - 1); |
368 | write (STDERR_FILENO, APL_NAME, sizeof (APL_NAME) - 1); |
356 | write (STDERR_FILENO, RESNAME, sizeof (RESNAME) - 1); |
369 | |
357 | |
370 | switch (type) |
358 | switch (type) |
371 | { |
359 | { |
372 | case 0: /* brief listing */ |
360 | case 0: /* brief listing */ |
373 | fprintf (stderr, " [-help] [--help]\n"); |
361 | fprintf (stderr, " [-help] [--help]\n"); |
… | |
… | |
570 | * quarks will be something like |
558 | * quarks will be something like |
571 | * "rxvt" "keysym" "0xFF01" |
559 | * "rxvt" "keysym" "0xFF01" |
572 | * value will be a string |
560 | * value will be a string |
573 | */ |
561 | */ |
574 | /* ARGSUSED */ |
562 | /* ARGSUSED */ |
575 | bool |
563 | int |
576 | rxvt_define_key(XrmDatabase *database __attribute__((unused)), XrmBindingList bindings __attribute__((unused)), XrmQuarkList quarks, XrmRepresentation *type __attribute__((unused)), XrmValue *value, XPointer closure __attribute__((unused))) |
564 | rxvt_define_key (XrmDatabase *database __attribute__((unused)), |
|
|
565 | XrmBindingList bindings __attribute__((unused)), |
|
|
566 | XrmQuarkList quarks, |
|
|
567 | XrmRepresentation *type __attribute__((unused)), |
|
|
568 | XrmValue *value, |
|
|
569 | XPointer closure __attribute__((unused))) |
577 | { |
570 | { |
578 | int last; |
571 | int last; |
579 | |
572 | |
580 | for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ |
573 | for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ |
581 | ; |
574 | ; |
… | |
… | |
762 | char *localepath = NULL; |
755 | char *localepath = NULL; |
763 | |
756 | |
764 | if (locale != NULL) |
757 | if (locale != NULL) |
765 | { /* XXX: must limit length of string */ |
758 | { /* XXX: must limit length of string */ |
766 | localepath = (char *)rxvt_malloc (256); |
759 | localepath = (char *)rxvt_malloc (256); |
767 | sprintf (localepath, XAPPLOADDIRLOCALE "/" APL_SUBCLASS, |
760 | sprintf (localepath, XAPPLOADDIRLOCALE "/" RESCLASS, |
768 | (int) (258 - sizeof (XAPPLOADDIRLOCALE) - sizeof (APL_SUBCLASS)), |
761 | (int) (258 - sizeof (XAPPLOADDIRLOCALE) - sizeof (RESCLASS)), |
769 | locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ |
762 | locale); /* 258 = 255 + 4 (-.*s) - 1 (/) */ |
770 | } |
763 | } |
771 | |
764 | |
772 | { |
765 | { |
773 | # endif |
766 | # endif |
… | |
… | |
828 | |
821 | |
829 | /* Add in Rxvt file */ |
822 | /* Add in Rxvt file */ |
830 | # if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
823 | # if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
831 | if (localepath == NULL || (rdb1 = XrmGetFileDatabase (localepath)) == NULL) |
824 | if (localepath == NULL || (rdb1 = XrmGetFileDatabase (localepath)) == NULL) |
832 | # endif |
825 | # endif |
833 | rdb1 = XrmGetFileDatabase (XAPPLOADDIR "/" APL_SUBCLASS); |
826 | rdb1 = XrmGetFileDatabase (XAPPLOADDIR "/" RESCLASS); |
|
|
827 | |
834 | if (rdb1 != NULL) |
828 | if (rdb1 != NULL) |
835 | XrmMergeDatabases (rdb1, &database); |
829 | XrmMergeDatabases (rdb1, &database); |
836 | |
830 | |
837 | /* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */ |
831 | /* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */ |
838 | if ((xe = (char *)getenv ("XAPPLRESDIR")) != NULL) |
832 | if ((xe = (char *)getenv ("XAPPLRESDIR")) != NULL) |
839 | { |
833 | { |
840 | sprintf (fname, "%-.*s/" APL_SUBCLASS, sizeof (fname) |
834 | sprintf (fname, "%-.*s/" RESCLASS, sizeof (fname) |
841 | - sizeof (APL_SUBCLASS) - 2, xe); |
835 | - sizeof (RESCLASS) - 2, xe); |
842 | if ((rdb1 = XrmGetFileDatabase (fname)) != NULL) |
836 | if ((rdb1 = XrmGetFileDatabase (fname)) != NULL) |
843 | XrmMergeDatabases (rdb1, &database); |
837 | XrmMergeDatabases (rdb1, &database); |
844 | } |
838 | } |
845 | |
839 | |
846 | XrmSetDatabase (display, database); |
840 | XrmSetDatabase (display, database); |
… | |
… | |
860 | |
854 | |
861 | p = XGetDefault (display, name, kw); |
855 | p = XGetDefault (display, name, kw); |
862 | p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); |
856 | p0 = XGetDefault (display, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw); |
863 | if (p == NULL || (p0 && STRCMP (p, p0) == 0)) |
857 | if (p == NULL || (p0 && STRCMP (p, p0) == 0)) |
864 | { |
858 | { |
865 | p = XGetDefault (display, APL_SUBCLASS, kw); |
859 | p = XGetDefault (display, RESCLASS, kw); |
|
|
860 | #ifdef RESFALLBACK |
866 | if (p == NULL || (p0 && STRCMP (p, p0) == 0)) |
861 | if (p == NULL || (p0 && STRCMP (p, p0) == 0)) |
867 | p = XGetDefault (display, APL_CLASS, kw); |
862 | p = XGetDefault (display, RESFALLBACK, kw); |
|
|
863 | #endif |
868 | } |
864 | } |
|
|
865 | |
869 | if (p == NULL && p0) |
866 | if (p == NULL && p0) |
870 | p = p0; |
867 | p = p0; |
|
|
868 | |
871 | if (p) |
869 | if (p) |
872 | { |
870 | { |
873 | rs[optList[entry].doff] = p; |
871 | rs[optList[entry].doff] = p; |
874 | |
872 | |
875 | if (optList_isBool (entry)) |
873 | if (optList_isBool (entry)) |
… | |
… | |
894 | # ifdef XrmEnumOneLevel |
892 | # ifdef XrmEnumOneLevel |
895 | # ifdef KEYSYM_RESOURCE |
893 | # ifdef KEYSYM_RESOURCE |
896 | name_prefix[0] = XrmStringToName (name); |
894 | name_prefix[0] = XrmStringToName (name); |
897 | name_prefix[1] = XrmStringToName ("keysym"); |
895 | name_prefix[1] = XrmStringToName ("keysym"); |
898 | name_prefix[2] = NULLQUARK; |
896 | name_prefix[2] = NULLQUARK; |
899 | class_prefix[0] = XrmStringToName (APL_SUBCLASS); |
897 | class_prefix[0] = XrmStringToName (RESCLASS); |
900 | class_prefix[1] = XrmStringToName ("Keysym"); |
898 | class_prefix[1] = XrmStringToName ("Keysym"); |
901 | class_prefix[2] = NULLQUARK; |
899 | class_prefix[2] = NULLQUARK; |
902 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
900 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
903 | XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix, |
901 | XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix, |
904 | XrmEnumOneLevel, rxvt_define_key, NULL); |
902 | XrmEnumOneLevel, rxvt_define_key, NULL); |
|
|
903 | # ifdef RESFALLBACK |
905 | name_prefix[0] = XrmStringToName (APL_CLASS); |
904 | name_prefix[0] = XrmStringToName (RESFALLBACK); |
906 | name_prefix[1] = XrmStringToName ("keysym"); |
905 | name_prefix[1] = XrmStringToName ("keysym"); |
907 | class_prefix[0] = XrmStringToName (APL_CLASS); |
906 | class_prefix[0] = XrmStringToName (RESFALLBACK); |
908 | class_prefix[1] = XrmStringToName ("Keysym"); |
907 | class_prefix[1] = XrmStringToName ("Keysym"); |
909 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
908 | /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ |
910 | XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix, |
909 | XrmEnumerateDatabase (XrmGetDatabase (display), name_prefix, class_prefix, |
911 | XrmEnumOneLevel, rxvt_define_key, NULL); |
910 | XrmEnumOneLevel, rxvt_define_key, NULL); |
|
|
911 | # endif |
912 | # endif |
912 | # endif |
913 | # endif |
913 | # endif |
914 | |
914 | |
915 | # else /* USE_XGETDEFAULT */ |
915 | # else /* USE_XGETDEFAULT */ |
916 | /* get resources the hard way, but save lots of memory */ |
916 | /* get resources the hard way, but save lots of memory */ |
… | |
… | |
954 | * Also, use a special sub-class so that we can use either or both of |
954 | * Also, use a special sub-class so that we can use either or both of |
955 | * "XTerm" and "Rxvt" as class names. |
955 | * "XTerm" and "Rxvt" as class names. |
956 | */ |
956 | */ |
957 | |
957 | |
958 | get_xdefaults (fd, name); |
958 | get_xdefaults (fd, name); |
959 | get_xdefaults (fd, APL_SUBCLASS); |
959 | get_xdefaults (fd, RESCLASS); |
|
|
960 | # ifdef RESFALLBACK |
|
|
961 | get_xdefaults (fd, RESFALLBACK); |
|
|
962 | # endif |
960 | |
963 | |
961 | # if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR) |
964 | # if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR) |
962 | |
965 | |
963 | { |
966 | { |
964 | FILE *ad = NULL; |
967 | FILE *ad = NULL; |
965 | |
968 | |
966 | # if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
969 | # if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
967 | if (localepath == NULL || (ad = fopen (localepath, "r")) == NULL) |
970 | if (localepath == NULL || (ad = fopen (localepath, "r")) == NULL) |
968 | # endif |
971 | # endif |
969 | ad = fopen (XAPPLOADDIR "/" APL_SUBCLASS, "r"); |
972 | ad = fopen (XAPPLOADDIR "/" RESCLASS, "r"); |
970 | if (ad != NULL) |
973 | if (ad != NULL) |
971 | { |
974 | { |
972 | get_xdefaults (ad, APL_SUBCLASS); |
975 | get_xdefaults (ad, RESCLASS); |
973 | get_xdefaults (ad, ""); |
976 | get_xdefaults (ad, ""); |
974 | fclose (ad); |
977 | fclose (ad); |
975 | } |
978 | } |
976 | } |
979 | } |
977 | # endif /* XAPPLOADDIR */ |
980 | # endif /* XAPPLOADDIR */ |
978 | |
981 | |
979 | get_xdefaults (fd, APL_CLASS); |
|
|
980 | get_xdefaults (fd, ""); /* partial match */ |
982 | get_xdefaults (fd, ""); /* partial match */ |
981 | if (fd != NULL) |
983 | if (fd != NULL) |
982 | fclose (fd); |
984 | fclose (fd); |
983 | # endif /* USE_XGETDEFAULT */ |
985 | # endif /* USE_XGETDEFAULT */ |
984 | |
986 | |
… | |
… | |
996 | |
998 | |
997 | /* |
999 | /* |
998 | * even without resources, at least do this setup for command-line |
1000 | * even without resources, at least do this setup for command-line |
999 | * options and command-line long options |
1001 | * options and command-line long options |
1000 | */ |
1002 | */ |
1001 | #ifdef MULTICHAR_SET |
|
|
1002 | set_multichar_encoding (rs[Rs_multichar_encoding]); |
|
|
1003 | #endif |
|
|
1004 | #ifdef GREEK_SUPPORT |
|
|
1005 | /* this could be a function in grkelot.c */ |
|
|
1006 | /* void set_greek_keyboard (const char * str); */ |
|
|
1007 | if (rs[Rs_greek_keyboard]) |
|
|
1008 | { |
|
|
1009 | if (!STRCMP (rs[Rs_greek_keyboard], "iso")) |
|
|
1010 | greek_setmode (GREEK_ELOT928); /* former -grk9 */ |
|
|
1011 | else if (!STRCMP (rs[Rs_greek_keyboard], "ibm")) |
|
|
1012 | greek_setmode (GREEK_IBM437); /* former -grk4 */ |
|
|
1013 | } |
|
|
1014 | { |
|
|
1015 | KeySym sym; |
|
|
1016 | |
|
|
1017 | if (rs[Rs_greektoggle_key] |
|
|
1018 | && ((sym = XStringToKeysym (rs[Rs_greektoggle_key])) != 0)) |
|
|
1019 | ks_greekmodeswith = sym; |
|
|
1020 | } |
|
|
1021 | #endif /* GREEK_SUPPORT */ |
|
|
1022 | |
1003 | |
1023 | #if defined (HOTKEY_CTRL) || defined (HOTKEY_META) |
1004 | #if defined (HOTKEY_CTRL) || defined (HOTKEY_META) |
1024 | |
|
|
1025 | { |
|
|
1026 | KeySym sym; |
1005 | KeySym sym; |
1027 | |
1006 | |
1028 | if (rs[Rs_bigfont_key] |
1007 | if (rs[Rs_bigfont_key] |
1029 | && ((sym = XStringToKeysym (rs[Rs_bigfont_key])) != 0)) |
1008 | && ((sym = XStringToKeysym (rs[Rs_bigfont_key])) != 0)) |
1030 | ks_bigfont = sym; |
1009 | ks_bigfont = sym; |
1031 | if (rs[Rs_smallfont_key] |
1010 | if (rs[Rs_smallfont_key] |
1032 | && ((sym = XStringToKeysym (rs[Rs_smallfont_key])) != 0)) |
1011 | && ((sym = XStringToKeysym (rs[Rs_smallfont_key])) != 0)) |
1033 | ks_smallfont = sym; |
1012 | ks_smallfont = sym; |
1034 | } |
|
|
1035 | #endif |
1013 | #endif |
1036 | } |
1014 | } |
1037 | |
1015 | |
1038 | /*}}} */ |
1016 | /*}}} */ |
1039 | /*----------------------- end-of-file (C source) -----------------------*/ |
1017 | /*----------------------- end-of-file (C source) -----------------------*/ |