--- rxvt-unicode/src/main.C 2003/12/18 05:45:11 1.15 +++ rxvt-unicode/src/main.C 2003/12/18 07:31:19 1.16 @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: main.c *----------------------------------------------------------------------* - * $Id: main.C,v 1.15 2003/12/18 05:45:11 pcg Exp $ + * $Id: main.C,v 1.16 2003/12/18 07:31:19 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -51,9 +51,9 @@ void rxvt_set_locale (const char *locale) { - if (locale && strncmp (locale, curlocale, 128)) + if (locale && STRNCMP (locale, curlocale, 128)) { - strncpy (curlocale, locale, 128); + STRNCPY (curlocale, locale, 128); setlocale (LC_CTYPE, curlocale); } } @@ -204,17 +204,12 @@ rxvt_privileges (this, SAVE); rxvt_privileges (this, IGNORE); -#if HAVE_XSETLOCALE || HAVE_SETLOCALE - locale = strdup (setlocale (LC_CTYPE, "")); -#endif -#if HAVE_NL_LANGINFO - codeset = strdup (nl_langinfo (CODESET)); -#endif - init_secondary (); const char **cmd_argv = init_resources (argc, argv); + set_locale (""); + #if (MENUBAR_MAX) rxvt_menubar_read (this, rs[Rs_menu]); #endif @@ -1075,18 +1070,6 @@ XFree(preedit_attr); } -/* EXTPROTO */ -void -rxvt_setTermFontSet(pR_ int idx) -{ - char *string; - long length; - int success = 0; - - if (idx < 0 || idx >= MAX_NFONTS) - return; -} - /* INTPROTO */ void rxvt_setPreeditArea (pR_ XRectangle * preedit_rect, XRectangle * status_rect, @@ -1131,86 +1114,11 @@ } /* - * X manual pages and include files don't match on some systems: - * some think this is an XIDProc and others an XIMProc so we can't - * use the first argument - need to update this to be nice for - * both types via some sort of configure detection - */ -/* ARGSUSED */ -/* EXTPROTO */ -void -rxvt_IMInstantiateCallback(Display * unused - __attribute__ ((unused)), XPointer client_data - __attribute__ ((unused)), XPointer call_data - __attribute__ ((unused))) -{ - dR; - int i, found, had_im; - const char *p; - char **s; - char buf[IMBUFSIZ]; - - D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); - if (R->Input_Context) - return; - -#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) - if (R->rs[Rs_imLocale]) - setlocale (LC_CTYPE, R->rs[Rs_imLocale]); -#endif - - p = R->rs[Rs_inputMethod]; - if (p && *p) - { - bool found = false; - - s = rxvt_splitcommastring (p); - for (i = 0; s[i]; i++) - { - if (*s[i]) - { - STRCPY (buf, "@im="); - STRNCAT (buf, s[i], IMBUFSIZ - 5); - if ((p = XSetLocaleModifiers (buf)) && *p - && rxvt_IM_get_IC (aR)) - { - found = true; - break; - } - } - } - for (i = 0; s[i]; i++) - free(s[i]); - free(s); - - if (found) - goto done; - } - -/* try with XMODIFIERS env. var. */ - if ((p = XSetLocaleModifiers ("")) && *p - && rxvt_IM_get_IC (aR)) - goto done; - -/* try with no modifiers base IF the user didn't specify an IM */ - if ((p = XSetLocaleModifiers ("@im=none")) && *p - && rxvt_IM_get_IC (aR) == True) - goto done; - -done: -#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) - if (R->rs[Rs_imLocale]) - setlocale (LC_CTYPE, R->locale); -#endif -} - -/* * Try to open a XIM with the current modifiers, then see if we can * open a suitable preedit type */ -/* INTPROTO */ -Bool -rxvt_IM_get_IC(pR) +static Bool +rxvt_IM_get_IC (pR) { int i, j, found; XIM xim; @@ -1224,12 +1132,12 @@ XIMCallback ximcallback; D_MAIN((stderr, "rxvt_IM_get_IC()")); - xim = XOpenIM(R->Xdisplay, NULL, NULL, NULL); + xim = XOpenIM (R->Xdisplay, NULL, NULL, NULL); if (xim == NULL) return False; xim_styles = NULL; - if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) + if (XGetIMValues (xim, XNQueryInputStyle, &xim_styles, NULL) || !xim_styles || !xim_styles->count_styles) { XCloseIM(xim); return False; @@ -1264,7 +1172,7 @@ ximcallback.callback = rxvt_IMDestroyCallback; -/* XXX: not sure why we need this (as well as IC one below) */ + /* XXX: not sure why we need this (as well as IC one below) */ XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL); preedit_attr = status_attr = NULL; @@ -1322,6 +1230,80 @@ return True; } +/* + * X manual pages and include files don't match on some systems: + * some think this is an XIDProc and others an XIMProc so we can't + * use the first argument - need to update this to be nice for + * both types via some sort of configure detection + */ +/* ARGSUSED */ +/* EXTPROTO */ +void +rxvt_IMInstantiateCallback(Display * unused + __attribute__ ((unused)), XPointer client_data + __attribute__ ((unused)), XPointer call_data + __attribute__ ((unused))) +{ + dR; + int i, found, had_im; + const char *p; + char **s; + char buf[IMBUFSIZ]; + + D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); + if (R->Input_Context) + return; + +#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) + if (R->rs[Rs_imLocale]) + setlocale (LC_CTYPE, R->rs[Rs_imLocale]); +#endif + + p = R->rs[Rs_inputMethod]; + if (p && *p) + { + bool found = false; + + s = rxvt_splitcommastring (p); + for (i = 0; s[i]; i++) + { + if (*s[i]) + { + STRCPY (buf, "@im="); + STRNCAT (buf, s[i], IMBUFSIZ - 5); + if ((p = XSetLocaleModifiers (buf)) && *p + && rxvt_IM_get_IC (aR)) + { + found = true; + break; + } + } + } + for (i = 0; s[i]; i++) + free(s[i]); + free(s); + + if (found) + goto done; + } + +/* try with XMODIFIERS env. var. */ + if ((p = XSetLocaleModifiers ("")) && *p + && rxvt_IM_get_IC (aR)) + goto done; + +/* try with no modifiers base IF the user didn't specify an IM */ + if ((p = XSetLocaleModifiers ("@im=none")) && *p + && rxvt_IM_get_IC (aR) == True) + goto done; + +done: +#if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) + if (R->rs[Rs_imLocale]) + setlocale (LC_CTYPE, R->locale); +#endif +} + /* EXTPROTO */ void rxvt_IMSetStatusPosition(pR)