Hi, At Fri, 01 Feb 2002 13:21:00 +0900, Tomohiro KUBOTA wrote:
> Thank you. I tried implementation last night and it is working > almost well. Here is the patch. This patch adds following command line options: -/+lc to turn on/off calling "luit" --lcc to specify path for "luit" This patch adds following resources: "locale" (class "Locale") to turn on/off calling "luit" "true"/"on"/"1" means always calls luit, "false"/"off"/"0" means never calls luit. If "auto" (indeed, all other than above), luit is called only ja/ko/th/zh locales (other than UTF-8 locales). In "auto" and in other locales, UTF-8 mode is automatically choosed (command line option -/+u8 and resource utf8 are overrided). "localeFilter" (class "LocaleFilter") to specify path for "luit". The default is "/usr/X11R6/bin/luit". I'd like to change this to be changable according to XFree86 installation process but I don't know how to do this. I think the roles of -/+lc and -/+u8 interferes each other. Thus, I designed -/+u8 to be completely ignored in "locale: auto" mode. (Instead, in "locale: auto" mode, -/+u8 is automatically determined.) Since UTF-8 mode is forced to be enabled in "locale: true" mode, -/+u8 is effective only in "locale: false" mode. ----------from here diff -u xterm-20020130/charproc.c xterm-20020130-luit/charproc.c --- xterm-20020130/charproc.c Sun Jan 20 10:58:47 2002 +++ xterm-20020130-luit/charproc.c Sat Feb 2 00:00:27 2002 @@ -565,6 +565,8 @@ {XtNutf8, XtCUtf8, XtRInt, sizeof(int), XtOffsetOf(XtermWidgetRec, screen.utf8_mode), XtRString, defaultUTF8}, +Sres(XtNlocale, XtCLocale, misc.locale_str, +"False"), +Sres(XtNlocaleFilter, XtCLocaleFilter, misc.localefilter, +DEFLOCALEFILTER), Bres(XtNwideChars, XtCWideChars, screen.wide_chars, FALSE), Sres(XtNwideBoldFont, XtCWideBoldFont, misc.f_wb, DEFWIDEBOLDFONT), Sres(XtNwideFont, XtCWideFont, misc.f_w, DEFWIDEFONT), @@ -4287,6 +4289,10 @@ Boolean color_ok; #endif char *s; +#if OPT_WIDE_CHARS + unsigned char *locale; + char locale_string[20]; +#endif /* Zero out the entire "screen" component of "wnew" widget, then do * field-by-field assignment of "screen" fields that are named in the @@ -4531,6 +4537,45 @@ #if OPT_WIDE_CHARS init_Bres(screen.wide_chars); + if ((locale = getenv("LC_ALL")) == 0 || *locale == '\0') + if ((locale = getenv("LC_CTYPE")) == 0 || *locale == '\0') + if ((locale = getenv("LANG")) == 0 || *locale == '\0') + locale = NULL; + for (i=0; i<19; i++) { + if ((locale_string[i] = toupper(request->misc.locale_str[i])) == 0) + break; + } + locale_string[19] = 0; + + if (strcmp(locale_string, "TRUE") == 0 || + strcmp(locale_string, "ON") == 0 || + strcmp(locale_string, "1") == 0) { + request->misc.locale = 1; + request->screen.utf8_mode = 2; + } else if (strcmp(locale_string, "FALSE") == 0 || + strcmp(locale_string, "OFF") == 0 || + strcmp(locale_string, "0") == 0) { + /* when false ... original value of utf8_mode is effective */ + request->misc.locale = 0; + } else { /* auto mode ... override utf8_mode */ + unsigned int lang; + if (locale !=NULL && strlen(locale) > 1 && + strstr(locale, "UTF-8") == NULL && + ((lang = locale[0]*256+locale[1]) == 'j'*256+'a' || + lang == 'k'*256+'o' || lang == 't'*256+'h' || + lang == 'z'*256+'h')) { + request->misc.locale = 1; + request->screen.utf8_mode = 2; + } else if (locale != NULL && strstr(locale, "UTF-8") != NULL) { + request->misc.locale = 0; + request->screen.utf8_mode = 2; + } else { + request->misc.locale = 0; + request->screen.utf8_mode = 0; + } + } + + init_Bres(misc.locale); if (request->screen.utf8_mode) { wnew->screen.wide_chars = True; wnew->screen.utf8_mode = 2; /* disable further change */ diff -u xterm-20020130/main.c xterm-20020130-luit/main.c --- xterm-20020130/main.c Sun Jan 20 10:58:51 2002 +++ xterm-20020130-luit/main.c Sat Feb 2 00:03:45 2002 @@ -891,6 +891,9 @@ #if OPT_WIDE_CHARS {"-u8", "*utf8", XrmoptionNoArg, (caddr_t) "2"}, {"+u8", "*utf8", XrmoptionNoArg, (caddr_t) "0"}, +{"-lc", "*locale", XrmoptionNoArg, (caddr_t) "True"}, +{"+lc", "*locale", XrmoptionNoArg, (caddr_t) "False"}, +{"-lcc", "*localeFilter",XrmoptionSepArg, (caddr_t) NULL}, #endif {"-ulc", "*colorULMode", XrmoptionNoArg, (caddr_t) "off"}, {"+ulc", "*colorULMode", XrmoptionNoArg, (caddr_t) "on"}, @@ -1032,6 +1035,8 @@ { "-tn name", "TERM environment variable name" }, #if OPT_WIDE_CHARS { "-/+u8", "turn on/off UTF-8 mode (implies wide-characters)" }, +{ "-/+lc", "turn on/off locale mode using luit" }, +{ "--lcc path", "filename of locale converter (luit)" }, #endif { "-/+ulc", "turn off/on display of underline as color" }, #ifdef HAVE_UTMP @@ -2010,6 +2015,17 @@ *command_to_exec)); XtSetValues (toplevel, args, 2); + } + if (term->misc.locale) { + if (command_to_exec) { + command_to_exec --; /* This should be possible */ + command_to_exec[0] = term->misc.localefilter; + } else { + static char *luit[2]; + luit[0] = term->misc.localefilter; + luit[1] = NULL; + command_to_exec = luit; + } } #if OPT_TEK4014 diff -u xterm-20020130/main.h xterm-20020130-luit/main.h --- xterm-20020130/main.h Thu Sep 27 08:03:34 2001 +++ xterm-20020130-luit/main.h Sat Feb 2 00:05:58 2002 @@ -36,3 +36,4 @@ #define DEFBORDER 2 #define DEFFACENAME NULL #define DEFFACESIZE 14 +#define DEFLOCALEFILTER "/usr/X11R6/bin/luit" diff -u xterm-20020130/ptyx.h xterm-20020130-luit/ptyx.h --- xterm-20020130/ptyx.h Sun Jan 20 10:58:51 2002 +++ xterm-20020130-luit/ptyx.h Sat Feb 2 00:03:12 2002 @@ -1331,6 +1331,9 @@ #if OPT_WIDE_CHARS char *f_w; char *f_wb; + Boolean locale; + char *locale_str; + char *localefilter; #endif #if OPT_INPUT_METHOD char *f_x; diff -u xterm-20020130/xterm.h xterm-20020130-luit/xterm.h --- xterm-20020130/xterm.h Sun Jan 20 10:58:52 2002 +++ xterm-20020130-luit/xterm.h Sat Feb 2 00:00:47 2002 @@ -351,6 +351,8 @@ #define XtNutf8 "utf8" #define XtNvisualBell "visualBell" #define XtNwideBoldFont "wideBoldFont" +#define XtNlocale "locale" +#define XtNlocaleFilter "localeFilter" #define XtNwideChars "wideChars" #define XtNwideFont "wideFont" #define XtNximFont "ximFont" @@ -439,6 +441,8 @@ #define XtCUtf8 "Utf8" #define XtCVisualBell "VisualBell" #define XtCWideBoldFont "WideBoldFont" +#define XtCLocale "Locale" +#define XtCLocaleFilter "LocaleFilter" #define XtCWideChars "WideChars" #define XtCWideFont "WideFont" #define XtCXimFont "XimFont" ----------till here --- Tomohiro KUBOTA <[EMAIL PROTECTED]> http://www.debian.or.jp/~kubota/ "Introduction to I18N" http://www.debian.org/doc/manuals/intro-i18n/ _______________________________________________ I18n mailing list [EMAIL PROTECTED] http://XFree86.Org/mailman/listinfo/i18n