Release 5 Public Patch #23 MIT X Consortium To apply this patch: cd to the top of the source tree (to the directory containing the "mit" and "contrib" subdirectories) and do: patch -p -s < ThisFile Patch will work silently unless an error occurs. You will likely get 97 "File exists" warning messages of the form: mkdir: : File exists which can be ignored. If you want to watch patch do its thing, leave out the "-s" argument to patch. This patch creates the following new files: mit/lib/X/Ximp/XimpLocal.c mit/lib/X/Ximp/XimpParser.c mit/lib/nls/Ximp/locale.alias mit/lib/nls/Ximp/C/Codeset.cpp mit/lib/nls/Ximp/iso8859/Codeset1.cpp mit/lib/nls/Ximp/iso8859/Codeset2.cpp mit/lib/nls/Ximp/iso8859/Codeset3.cpp mit/lib/nls/Ximp/iso8859/Codeset5.cpp mit/lib/nls/Ximp/iso8859/Codeset7.cpp mit/lib/nls/Ximp/iso8859/Compose mit/lib/nls/Ximp/iso8859/Imakefile mit/lib/nls/Ximp/ja_JP.EUC/Codeset.cpp mit/lib/nls/Ximp/ja_JP.JIS/Codeset.cpp mit/lib/nls/Ximp/ja_JP.JIS/Imakefile mit/lib/nls/Ximp/ja_JP.SJIS/Codeset.cpp mit/lib/nls/Ximp/ko/Codeset.cpp mit/lib/nls/Ximp/ko/Imakefile mit/lib/nls/Ximp/zh/Codeset.cpp mit/lib/nls/Ximp/zh/Imakefile mit/lib/nls/Ximp/zh_TW/Codeset.cpp mit/lib/nls/Ximp/zh_TW/Imakefile If you are using a symbolic link tree, you will need to create new links. Finally, if you are on a Sony system, or otherwise use the Ximp internationalization code in Xlib by setting the "BuildXimp" configuration variable to YES (in your site.def file or in the vendor.cf file), then to rebuild after applying this patch, cd to the "mit" subdirectory and do: make Everything >& every.log If you are not on a Sony system and do not set BuildXimp to YES, then you do not have to rebuild. Brief notes on what this patch fixes: Xlib: (Ximp) fix synchronization problems Xlib: (Ximp) add locale name aliasing Xlib: (Ximp) add support for new locales Xlib: (Ximp) add local compose processing Prereq: public-patch-22 *** /tmp/,RCSt1006225 Tue Mar 9 14:40:48 1993 --- mit/bug-report Tue Mar 9 14:37:04 1993 *************** *** 2,8 **** Subject: [area]: [synopsis] [replace with actual area and short description] VERSION: ! R5, public-patch-22 [MIT public patches will edit this line to indicate the patch level] CLIENT MACHINE and OPERATING SYSTEM: --- 2,8 ---- Subject: [area]: [synopsis] [replace with actual area and short description] VERSION: ! R5, public-patch-23 [MIT public patches will edit this line to indicate the patch level] CLIENT MACHINE and OPERATING SYSTEM: *** /tmp/,RCSt1005203 Tue Mar 9 13:45:42 1993 --- mit/lib/X/Imakefile Tue Mar 9 13:45:45 1993 *************** *** 1,4 **** ! XCOMM $XConsortium: Imakefile,v 1.129 91/12/17 17:54:51 rws Exp $ #define DoNormalLib NormalLibX #define DoSharedLib SharedLibX #define DoDebugLib DebugLibX --- 1,4 ---- ! XCOMM $XConsortium: Imakefile,v 1.129.1.1 93/03/09 13:31:06 rws Exp $ #define DoNormalLib NormalLibX #define DoSharedLib SharedLibX #define DoDebugLib DebugLibX *************** *** 856,863 **** #if BuildXimp ! XFILESEARCHPATHDEFAULT = XFileSearchPathDefault ! SRCH_DEFINES = -DXFILESEARCHPATHDEFAULT=\"$(XFILESEARCHPATHDEFAULT)\" LCHDRS = \ XIMProto.h \ --- 856,867 ---- #if BuildXimp ! #ifdef XlibI18nPath ! XLIBI18N_PATH = XlibI18nPath ! #else ! XLIBI18N_PATH = $(LIBDIR) ! #endif ! SRCH_DEFINES = -DXLIBI18N_PATH=\"$(XLIBI18N_PATH)\" LCHDRS = \ XIMProto.h \ *************** *** 879,884 **** --- 883,889 ---- XimpLCUtil.c \ XimpLCd.c \ XimpLkup.c \ + XimpLocal.c \ XimpMCT.c \ XimpMDrS.c \ XimpMEsc.c \ *************** *** 886,891 **** --- 891,897 ---- XimpMPer.c \ XimpMPrTxt.c \ XimpMTxtPr.c \ + XimpParser.c \ XimpPrTxt.c \ XimpTxtPr.c \ XimpRm.c \ *************** *** 923,928 **** --- 929,935 ---- XimpLCUtil.o \ XimpLCd.o \ XimpLkup.o \ + XimpLocal.o \ XimpMCT.o \ XimpMDrS.o \ XimpMEsc.o \ *************** *** 936,941 **** --- 943,949 ---- XimpWDrS.o \ XimpWEsc.o \ XimpWExt.o \ + XimpParser.o \ XimpWPer.o \ XimpWPrTxt.o \ XimpWTxtPr.o \ *************** *** 960,965 **** --- 968,974 ---- LinkSourceFile(XimpLCUtil.c,Ximp) @@\ LinkSourceFile(XimpLCd.c,Ximp) @@\ LinkSourceFile(XimpLkup.c,Ximp) @@\ + LinkSourceFile(XimpLocal.c,Ximp) @@\ LinkSourceFile(XimpMCT.c,Ximp) @@\ LinkSourceFile(XimpMDrS.c,Ximp) @@\ LinkSourceFile(XimpMEsc.c,Ximp) @@\ *************** *** 967,972 **** --- 976,982 ---- LinkSourceFile(XimpMPer.c,Ximp) @@\ LinkSourceFile(XimpMPrTxt.c,Ximp) @@\ LinkSourceFile(XimpMTxtPr.c,Ximp) @@\ + LinkSourceFile(XimpParser.c,Ximp) @@\ LinkSourceFile(XimpPrTxt.c,Ximp) @@\ LinkSourceFile(XimpRm.c,Ximp) @@\ LinkSourceFile(XimpSJIS.c,Ximp) @@\ *** /tmp/d03300 Tue Mar 9 09:16:46 1993 --- mit/lib/X/Ximp/XimpLCUtil.c Tue Mar 9 09:16:41 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpLCUtil.c,v 1.7 92/04/14 13:29:21 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpLCUtil.c,v 1.8 92/10/19 19:24:49 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 75,125 **** extern char *getenv(); #endif ! enum { ! CODESET, ! ENCODING, ! EXT_FONT, ! FONT, ! GL_ENCODING, ! GR_ENCODING, ! LENGTH, ! NAME, ! STRING ! } keyword_value; typedef struct KeywordRec { char *name; - int cmp_len; int value; } KeywordRec; static KeywordRec keyword_tbl[] = { ! { "CODESET", 7, CODESET }, ! { "ENCODING", 8, ENCODING }, ! { "EXT_FONT", 8, EXT_FONT }, ! { "FONT", 4, FONT }, ! { "GL", 2, GL_ENCODING }, ! { "GR", 2, GR_ENCODING }, ! { "LENGTH", 6, LENGTH }, ! { "NAME", 4, NAME }, 0, }; ! static int ! get_token(buf, len) ! char *buf; ! int len; { KeywordRec *keyword = keyword_tbl; ! while (keyword->name) { ! if (keyword->cmp_len <= len) ! if (_Ximp_NCompareISOLatin1(buf,keyword->name,keyword->cmp_len)==0) ! return keyword->value; ! keyword++; } ! return STRING; } static char * --- 75,170 ---- extern char *getenv(); #endif ! static void free_charset(); + static enum { + T_NONE = E_LAST, + T_CHARSET, + T_CODESET, + T_FALSE, + T_FONT, + T_INITIAL_STATE_GL, + T_INITIAL_STATE_GR, + T_LENGTH, + T_MB_CUR_MAX, + T_MB_ENCODING, + T_STRING, + T_STATE_DEPEND_ENCODING, + T_TRUE, + T_WC_ENCODING, + T_WC_ENCODING_MASK, + T_WC_SHIFT_BITS + } token_value; + typedef struct KeywordRec { char *name; int value; } KeywordRec; static KeywordRec keyword_tbl[] = { ! { "CHARSET", T_CHARSET }, ! { "CODESET", T_CODESET }, ! { "ENCODING", T_CHARSET }, ! { "FALSE", T_FALSE }, ! { "FONT", T_FONT }, ! { "GL", E_GL}, ! { "GR", E_GR}, ! { "INITIAL_STATE_GL", T_INITIAL_STATE_GL}, ! { "INITIAL_STATE_GR", T_INITIAL_STATE_GR}, ! { "LENGTH", T_LENGTH }, ! { "MB_ENCODING", T_MB_ENCODING }, ! { "MB_CUR_MAX", T_MB_CUR_MAX }, ! { "STATE_DEPEND_ENCODING", T_STATE_DEPEND_ENCODING }, ! { "TRUE", T_TRUE }, ! { "WC_ENCODING_MASK", T_WC_ENCODING_MASK }, ! { "WC_ENCODING", T_WC_ENCODING }, ! { "WC_SHIFT_BITS", T_WC_SHIFT_BITS }, ! { "", E_SS }, ! { "", E_LSL }, ! { "", E_LSR }, 0, }; ! #define SKIP_WHITE(str) \ ! while (*(str) == ' ' || *(str) == '\t' || *(str) == '\n') str++; ! #define SKIP_TO_WHITE(str) \ ! while (*(str) && *(str) != ' ' && *(str) != '\t' && *(str) != '\n') str++; ! ! static char * ! get_token(src, dst, token) ! char *src; ! char *dst; ! int *token; { KeywordRec *keyword = keyword_tbl; + char *str; + int len, tmp_len; ! SKIP_WHITE(src) ! str = src; ! SKIP_TO_WHITE(str) ! len = str - src; ! if (len == 0) ! return NULL; ! strncpy(dst, src, len); ! *token = T_STRING; ! ! for ( ; keyword->name; keyword++) { ! tmp_len = strlen(keyword->name); ! if (tmp_len > len) ! continue; ! ! if (!_Ximp_NCompareISOLatin1(dst, keyword->name, tmp_len)) { ! *token = keyword->value; ! len = tmp_len; ! break; ! } } ! ! dst[len] = '\0'; ! ! return src + len; } static char * *************** *** 145,505 **** return str; } ! static int def_line_no; ! static char *default_data[] = { ! "NAME C", ! "CODESET0", ! "Length 1", ! "GL", ! "Encoding", ! "ISO8859-1 GL", ! "Font", ! "ISO8859-1 GL", ! 0, ! }; ! ! static char * ! get_line(fd, buf, buf_len) ! FILE *fd; ! char *buf; ! int buf_len; { ! int length, token; ! if (fd) { ! while (fgets(buf, buf_len, fd)) { ! if (buf[0] == '#') ! continue; ! return buf; ! } ! return NULL; ! } else { ! if (default_data[def_line_no]) { ! strcpy(buf, default_data[def_line_no]); ! def_line_no++; ! return buf; ! } ! return NULL; } - } ! #ifndef XFILESEARCHPATHDEFAULT ! #define XFILESEARCHPATHDEFAULT "/usr/lib/X11/%L/%T/%N%S:/usr/lib/X11/%l/%T/%N%S:/usr/lib/X11/%T/%N%S" #endif ! #ifndef LIBDIR ! #define LIBDIR "/usr/lib/X11" ! #endif ! #define MAX_PATH 512 ! static FILE * ! open_codeset_file(locale, name) ! char *locale; ! char *name; { ! char ch, buf[BUFSIZE], *bufptr, *strptr1, *strptr2, *path; ! char lang[MAX_PATH], territory[MAX_PATH], codeset[MAX_PATH]; ! Bool first; FILE *fd; ! strptr1 = index(locale, '_'); ! strptr2 = index(locale, '.'); ! ! *lang = *territory = *codeset = 0; ! if (strptr1) { ! strncpy(lang, locale, strptr1 - locale); ! lang[strptr1 - locale] = 0; ! strptr1++; ! if (strptr2) { ! strncpy(territory, strptr1, strptr2 - strptr1); ! territory[strptr2 - strptr1] = 0; ! strcpy(codeset, strptr2 + 1); ! } else ! strcpy(territory, strptr1); ! } else { ! if (strptr2) { ! strncpy(lang, locale, strptr2 - locale); ! lang[strptr2 - locale] = 0; ! strcpy(codeset, strptr2 + 1); ! } else ! strcpy(lang, locale); ! } ! ! if ((path = getenv("XFILESEARCHPATH")) == NULL) ! path = XFILESEARCHPATHDEFAULT; ! first = True; ! bufptr = buf; ! while (1) { ! ch = *path++; ! if (ch != ':') ! first = False; ! switch (ch) { ! case ':': ! if (first) { ! strcpy(buf, name); ! bufptr += strlen(strptr1); ! } ! case '\0': ! end: ! *bufptr = 0; ! if (fd = fopen(buf, "r")) ! return fd; ! if (ch == '\0') { ! sprintf(buf, "%s/%s/%s", LIBDIR, locale, name); ! return fopen(buf, "r"); ! } ! first = True; ! bufptr = buf; continue; ! case '%': ! switch (ch = *path++) { ! case 'N': ! strptr1 = name; ! break; ! case 'L': ! strptr1 = locale; ! break; ! case 'l': ! strptr1 = lang; ! break; ! case 't': ! strptr1 = territory; ! break; ! case 'c': ! strptr1 = codeset; ! break; ! case '\0': ! goto end; ! case '%': ! case ':': ! *bufptr++ = ch; ! default: ! continue; ! } ! strcpy(bufptr, strptr1); ! bufptr += strlen(strptr1); continue; ! default: ! *bufptr++ = ch; ! break; } } } ! static int ! get_encoding(name, len) char *name; - int len; { ! EncodingRec *encoding_ptr, **table_ptr; ! table_ptr = encoding_table; ! while (encoding_ptr = *table_ptr++) ! if (_Ximp_NCompareISOLatin1(encoding_ptr->charset_name, name, len) == 0) ! return encoding_ptr->lindex; ! return -1; } ! #define CODESET_FILE "Codeset" Bool ! _Ximp_load_codeset_data(lcd) ! Ximp_XLCd lcd; { ! XLCdXimpRec *lcpart = lcd->ximp_lcpart; ! CodeSetRec codeset_tbl[MAX_CODESET], *codeset; ! FontSetDataRec font_data_tbl[MAX_FONTSET], *font_data; ! EncodingIndexRec *index_ptr; ! char buf[BUFSIZE], *bufptr; ! char name_buf[BUFSIZE], *name_bufptr; ! int token, last_token, word_len, lindex; ! int i, tmp, font_data_num, cur_num, max_num = -1; ! FILE *fd; ! fd = open_codeset_file(lcd->core.name, CODESET_FILE); ! if (fd == NULL) { ! if (strcmp(lcd->core.name, "C")) ! return False; ! def_line_no = 0; } ! codeset = codeset_tbl; ! for (i = 0; i < MAX_CODESET; i++, codeset++) { ! codeset->char_length = 1; ! codeset->msb_mask = GL; ! codeset->index_num = 0; ! codeset->encoding_index = NULL; } - lcpart->codeset_name = NULL; - lcpart->codeset = NULL; - lcpart->fontset_data = NULL; - codeset = codeset_tbl; - font_data_num = 0; - font_data = font_data_tbl; - name_bufptr = name_buf; - cur_num = 0; ! while (get_line(fd, buf, BUFSIZE)) { ! bufptr = buf; ! if ((bufptr = get_word(bufptr, &word_len)) == 0) continue; ! token = get_token(bufptr, word_len); ! bufptr += word_len; switch (token) { ! case NAME: ! if ((bufptr = get_word(bufptr, &word_len)) == 0) continue; ! if ((lcpart->codeset_name = Xmalloc(word_len + 1)) == NULL) goto error; ! strncpy(lcpart->codeset_name, bufptr, word_len); ! lcpart->codeset_name[word_len] = 0; ! break; ! case CODESET: ! bufptr--; ! tmp = *bufptr - '0'; ! if (tmp >= 0 && tmp <= 9) { ! cur_num = tmp; ! max_num = max(cur_num, max_num); ! codeset = codeset_tbl + cur_num; } ! break; ! case GL_ENCODING: ! case GR_ENCODING: ! codeset->msb_mask = (token == GL_ENCODING) ? GL : GR; ! break; ! case LENGTH: ! if ((bufptr = get_word(bufptr, &word_len)) == 0) continue; ! tmp = *bufptr - '0'; ! if (tmp >= 0 && tmp <= 9) ! codeset->char_length = tmp; ! break; ! case ENCODING: ! case FONT: ! case EXT_FONT: ! break; ! case STRING: ! bufptr -= word_len; ! if (last_token == ENCODING) { ! if ((lindex = get_encoding(bufptr, word_len)) == -1) continue; ! bufptr += word_len; ! if ((bufptr = get_word(bufptr, &word_len)) == 0) continue; - token = get_token(bufptr, word_len); - if (token != GL_ENCODING && token != GR_ENCODING) - continue; ! tmp = codeset->index_num; ! if (tmp == 0) ! index_ptr = (EncodingIndexRec *) ! Xmalloc(sizeof(EncodingIndexRec)); ! else ! index_ptr = (EncodingIndexRec *) ! Xrealloc(codeset->encoding_index, ! sizeof(EncodingIndexRec) * ! (tmp + 1)); ! if (index_ptr == NULL) goto error; ! codeset->encoding_index = index_ptr; ! index_ptr += tmp; ! index_ptr->lindex = lindex; ! index_ptr->msb_mask = (token == GL_ENCODING) ? GL : GR; ! codeset->index_num = tmp + 1; ! } else if (last_token == FONT || last_token == EXT_FONT) { ! strncpy(name_bufptr, bufptr, word_len); ! name_bufptr[word_len] = 0; ! ! bufptr += word_len; ! if ((bufptr = get_word(bufptr, &word_len)) == 0) continue; ! token = get_token(bufptr, word_len); ! if (token != GL_ENCODING && token != GR_ENCODING) ! continue; ! font_data->cset_number = cur_num; ! font_data->font_name = name_bufptr; ! font_data->msb_mask = (token == GL_ENCODING) ? GL : GR; ! font_data->ext_flag = (last_token == EXT_FONT); ! font_data++; ! font_data_num++; ! ! name_bufptr += strlen(name_bufptr) + 1; } continue; } - last_token = token; } ! max_num++; ! if (max_num == 0) ! goto error; ! if ((codeset = (CodeSetRec *) Xmalloc(max_num*sizeof(CodeSetRec))) == NULL) ! goto error; ! if ((font_data = (FontSetDataRec *) Xmalloc(font_data_num * ! sizeof(FontSetDataRec))) == NULL) ! goto error; ! if ((name_bufptr = (char *) Xmalloc(name_bufptr - name_buf)) == NULL) ! goto error; - lcpart->codeset_num = max_num; - lcpart->codeset = codeset; - lcpart->fontset_data_num = font_data_num; - lcpart->fontset_data = font_data; - for (i = 0; i < max_num; i++, codeset++) - *codeset = codeset_tbl[i]; - for (i = 0; i < font_data_num; i++, font_data++) { - *font_data = font_data_tbl[i]; - strcpy(name_bufptr, font_data->font_name); - font_data->font_name = name_bufptr; - name_bufptr += strlen(name_bufptr) + 1; - } - return True; error: ! codeset = codeset_tbl; ! for (i = 0; i < MAX_CODESET; i++, codeset++) ! if (codeset->encoding_index) ! Xfree(codeset->encoding_index); - if (lcpart->codeset_name) - Xfree(lcpart->codeset_name); - if (lcpart->codeset) - Xfree(lcpart->codeset); - if (lcpart->fontset_data) - Xfree(lcpart->fontset_data); - return False; } ! void ! _Ximp_free_codeset(lcd) ! Ximp_XLCd lcd; { ! XLCdXimpRec *lcpart = lcd->ximp_lcpart; ! CodeSetRec *codeset; ! FontSetDataRec *font_data; ! int i; ! if (lcpart->codeset_name) ! Xfree(lcpart->codeset_name); ! if (codeset = lcpart->codeset) { ! for (i = 0; i < lcpart->codeset_num; i++, codeset++) ! if (codeset->index_num) ! Xfree(codeset->encoding_index); ! Xfree(lcpart->codeset); } ! if (font_data = lcpart->fontset_data) { ! if (font_data->font_name) ! Xfree(font_data->font_name); ! Xfree(font_data); } } #ifdef X_NOT_STDC_ENV #ifndef toupper --- 190,722 ---- return str; } ! #ifndef XLIBI18N_PATH ! #define XLIBI18N_PATH "/usr/lib/X11" ! #endif ! FILE * ! _XlcOpenLocaleFile(dir, locale, name) ! char *dir; ! char *locale; ! char *name; { ! FILE *fd; ! char buf[BUFSIZE], locale_file[BUFSIZE]; ! if (locale) ! sprintf(locale_file, "%s/%s", locale, name); ! else ! strcpy(locale_file, name); ! ! if (dir) { ! sprintf(buf, "%s/%s", dir, locale_file); ! if (fd = fopen(buf, "r")) ! return fd; } ! if (dir = getenv("XLIBI18N_PATH")) { ! sprintf(buf, "%s/%s", dir, locale_file); ! if (fd = fopen(buf, "r")) ! return fd; ! } ! #ifdef sun ! if (dir = getenv("OPENWINHOME")) { ! sprintf(buf, "%s/lib/locale/%s", dir, locale_file); ! if (fd = fopen(buf, "r")) ! return fd; ! } #endif ! sprintf(buf, "%s/%s", XLIBI18N_PATH, locale_file); ! return fopen(buf, "r"); ! } ! #ifndef LOCALE_ALIAS ! #define LOCALE_ALIAS "locale.alias" ! #endif ! ! static Bool ! get_locale_name(locale, name_ret) ! char *locale; ! char *name_ret; { ! char *bufptr, buf[BUFSIZE]; ! int length; FILE *fd; ! if (fd = _XlcOpenLocaleFile(NULL, NULL, LOCALE_ALIAS)) { ! while (fgets(buf, BUFSIZE, fd)) { ! bufptr = get_word(buf, &length); ! if (bufptr == NULL) continue; ! bufptr[length] = '\0'; ! if (strcmp(locale, bufptr)) continue; ! ! bufptr += length + 1; ! bufptr = get_word(bufptr, &length); ! if (bufptr == NULL) ! continue; ! ! bufptr[length] = '\0'; ! locale = bufptr; ! break; } } + + if (fd) + fclose(fd); + + strcpy(name_ret, locale); + + return True; } ! static Bool ! set_locale_name(lcd, core_name, name) ! XimpLCd lcd; ! char *core_name; char *name; { ! char *language, *territory, *codeset, *str, buf[BUFSIZE]; ! int length; ! length = strcmp(core_name, name) ? strlen(core_name) : 0; ! length += strlen(name) * 2 + 5; ! str = (char *) Xmalloc(length); ! if (str == NULL) ! return False; ! ! strcpy(buf, name); ! ! if (codeset = rindex(buf, '.')) ! *codeset++ = '\0'; ! ! if (territory = rindex(buf, '_')) ! *territory++ = '\0'; ! ! language = buf; ! ! strcpy(str, core_name); ! lcd->core.name = str; ! if (strcmp(core_name, name)) { ! str += strlen(str) + 1; ! ! strcpy(str, name); ! } ! lcd->locale.name = str; ! str += strlen(str) + 1; ! ! if (language) ! strcpy(str, language); ! else ! *str = '\0'; ! lcd->locale.language = str; ! str += strlen(str) + 1; ! ! ! if (territory) ! strcpy(str, territory); ! else ! *str = '\0'; ! lcd->locale.territory = str; ! str += strlen(str) + 1; ! ! if (codeset) ! strcpy(str, codeset); ! else ! *str = '\0'; ! lcd->locale.codeset = str; ! ! return True; ! } ! ! XimpLCd ! _XlcCreateLC(core_name, methods, lc_methods) ! char *core_name; ! XLCdMethods methods; ! LCMethods lc_methods; ! { ! char name[BUFSIZE]; ! XimpLCd lcd; ! ! if (get_locale_name(core_name, name) == False) ! return (XimpLCd) NULL; ! lcd = (XimpLCd) Xmalloc(sizeof(XimpLCdRec)); ! if (lcd == NULL) ! return (XimpLCd) NULL; ! bzero((char *) lcd, sizeof(XimpLCdRec)); ! ! if (set_locale_name(lcd, core_name, name) == False) { ! _XlcDestroyLC(lcd); ! return (XimpLCd) NULL; ! } ! ! lcd->methods = methods; ! lcd->lc_methods = lc_methods; ! ! return lcd; } ! void ! _XlcDestroyLC(lcd) ! XimpLCd lcd; ! { ! if (lcd->core.name) ! XFree(lcd->core.name); ! ! XFree(lcd); ! } + static Bool + add_charset_list(codeset, charset) + CodeSet codeset; + CharSet charset; + { + CharSet *new; + int num; + + if (num = codeset->charset_num) + new = (CharSet *) Xrealloc(codeset->charset_list, + (num + 1) * sizeof(CharSet)); + else + new = (CharSet *) Xmalloc(sizeof(CharSet)); + + if (new == NULL) + return False; + + new[num++] = charset; + codeset->charset_list = new; + codeset->charset_num = num; + + return True; + } + + static CodeSet + add_codeset(locale) + Locale locale; + { + CodeSet new, *new_list; + int num; + + new = (CodeSet) Xmalloc(sizeof(CodeSetRec)); + if (new == NULL) + return NULL; + bzero((char *) new, sizeof(CodeSetRec)); + + if (num = locale->codeset_num) + new_list = (CodeSet *) Xrealloc(locale->codeset_list, + (num + 1) * sizeof(CodeSet)); + else + new_list = (CodeSet *) Xmalloc(sizeof(CodeSet)); + + if (new_list == NULL) + goto error; + + new_list[num] = new; + locale->codeset_list = new_list; + locale->codeset_num = num + 1; + + return new; + + error: + XFree(new); + + return NULL; + } + Bool ! _XlcAddParseList(locale, type, encoding, codeset) ! Locale locale; ! EncodingType type; ! char *encoding; ! CodeSet codeset; { ! ParseInfo new, *new_list; ! char *str; ! unsigned char ch; ! int num; ! str = (char *) Xmalloc(strlen(encoding) + 1); ! if (str == NULL) ! return False; ! strcpy(str, encoding); ! ! new = (ParseInfo) Xmalloc(sizeof(ParseInfoRec)); ! if (new == NULL) ! goto error; ! bzero((char *) new, sizeof(ParseInfoRec)); ! ! if (locale->mb_parse_table == NULL) { ! locale->mb_parse_table = (unsigned char *) Xmalloc(256); /* 2^8 */ ! if (locale->mb_parse_table == NULL) ! goto error; ! bzero((char *) locale->mb_parse_table, 256); } ! if (num = locale->mb_parse_list_num) ! new_list = (ParseInfo *) Xrealloc(locale->mb_parse_list, ! (num + 2) * sizeof(ParseInfo)); ! else { ! new_list = (ParseInfo *) Xmalloc(2 * sizeof(ParseInfo)); } ! if (new_list == NULL) ! goto error; ! ! new_list[num] = new; ! new_list[num + 1] = (ParseInfo) NULL; ! locale->mb_parse_list = new_list; ! locale->mb_parse_list_num = num + 1; ! ! ch = (unsigned char) *str; ! if (locale->mb_parse_table[ch] == 0) ! locale->mb_parse_table[ch] = num + 1; ! ! new->type = type; ! new->encoding = str; ! new->codeset = codeset; ! ! if (codeset->parse_info == NULL) ! codeset->parse_info = new; ! ! return True; ! ! error: ! XFree(str); ! if (new) ! XFree(new); ! ! return False; ! } ! ! static FontSetData ! add_fontset(locale) ! Locale locale; ! { ! FontSetData new; ! int num; ! ! if (num = locale->fontset_data_num) ! new = (FontSetData) Xrealloc(locale->fontset_data, ! (num + 1) * sizeof(FontSetDataRec)); ! else ! new = (FontSetData) Xmalloc(sizeof(FontSetDataRec)); ! ! if (new == NULL) ! return NULL; ! ! locale->fontset_data_num = num + 1; ! locale->fontset_data = new; ! ! new += num; ! bzero((char *) new, sizeof(FontSetDataRec)); ! ! return new; ! } ! ! Bool ! _XlcLoadCodeSet(lcd) ! XimpLCd lcd; ! { ! Locale locale = &lcd->locale; ! CodeSetRec *codeset; ! CharSet charset; ! FontSetData font_data; ! char *next, buf[BUFSIZE], tmp[256], tmp2[256]; ! int num, cur_num, token, category, type, tmp_token; ! unsigned long mask; ! FILE *fd = NULL; ! ! fd = _XlcOpenLocaleFile(NULL, locale->name, CODESET_FILE); ! ! if (fd == NULL && locale->language) ! fd = _XlcOpenLocaleFile(NULL, locale->language, CODESET_FILE); ! ! if (fd == NULL) ! return False; ! ! locale->codeset_num = 0; ! locale->fontset_data_num = 0; ! codeset = NULL; ! ! while (fgets(buf, BUFSIZE,fd)) { ! next = get_token(buf, tmp, &token); ! if (next == NULL) continue; ! switch (token) { ! case T_CODESET: ! next = get_token(next, tmp, &tmp_token); ! if (next == NULL) continue; ! cur_num = atoi(tmp); ! codeset = add_codeset(locale); ! if (codeset == NULL) goto error; ! codeset->cs_num = cur_num; ! category = token; ! continue; ! case E_GL: ! case E_GR: ! if (codeset == NULL) ! continue; ! codeset->side = (token == E_GL) ? GL : GR; ! continue; ! case T_LENGTH: ! case T_MB_CUR_MAX: ! case T_WC_SHIFT_BITS: ! next = get_token(next, tmp, &tmp_token); ! if (next == NULL) ! continue; ! num = *tmp - '0'; ! if (num >= 0 && num <= 9) { ! if (token == T_LENGTH && codeset) ! codeset->length = num; ! else if (token == T_MB_CUR_MAX) ! locale->mb_cur_max = num; ! else if (token == T_WC_SHIFT_BITS) ! locale->wc_shift_bits = num; } ! continue; ! case T_MB_ENCODING: ! if (codeset == NULL) continue; ! num = 0; ! type = E_SS; /* for BC */ ! while (next = get_token(next, tmp, &token)) { ! if (token == E_SS || token == E_LSL || token == E_LSR) { ! type = token; continue; + } + tmp2[num] = (char) strtol(tmp, NULL, 0); /* XXX */ + if (tmp2[num] == '\0') + break; + num++; + } + if (num == 0) + continue; + tmp2[num] = '\0'; + _XlcAddParseList(locale, type, tmp2, codeset); + continue; + case T_WC_ENCODING_MASK: + case T_WC_ENCODING: + next = get_token(next, tmp, &tmp_token); + if (next == NULL) + continue; + mask = (unsigned long) strtol(tmp, NULL, 0); /* XXX */ + if (token == T_WC_ENCODING_MASK) + locale->wc_encode_mask = mask; + else if (token == T_WC_ENCODING && codeset) + codeset->wc_encoding = mask; + continue; + case T_STATE_DEPEND_ENCODING: + next = get_token(next, tmp, &token); + if (next == NULL) + continue; + locale->state_dependent = (token == T_TRUE) ? True : False; + continue; + case T_INITIAL_STATE_GL: + case T_INITIAL_STATE_GR: + if (codeset == NULL) + continue; + if (token == T_INITIAL_STATE_GL) + locale->initial_state_GL = codeset; + else + locale->initial_state_GR = codeset; + continue; + case T_CHARSET: + case T_FONT: + category = token; + continue; + case T_STRING: + if (*tmp == '#') + continue; + if (category == T_CHARSET && codeset) { + next = get_token(next, tmp2, &token); + if (next == NULL || + token != E_GL && token != E_GR) + continue; ! charset = _XlcGetCharSetFromName(tmp, ! (token == E_GL) ? GL : GR); ! if (charset == NULL) continue; ! if (add_charset_list(codeset, charset) == False) goto error; ! } else if (category == T_FONT) { ! next = get_token(next, tmp2, &token); ! if (next == NULL || ! token != E_GL && token != E_GR) continue; ! ! font_data = add_fontset(locale); ! if (font_data == NULL) ! goto error; ! ! font_data->font_name = (char *) Xmalloc(strlen(tmp) + 1); ! if (font_data->font_name == NULL) ! goto error; ! strcpy(font_data->font_name, tmp); ! font_data->cs_num = cur_num; ! font_data->side = (token == E_GL) ? GL : GR; } continue; } } ! fclose(fd); return True; error: ! free_charset(lcd); ! fclose(fd); return False; } ! static void ! free_charset(lcd) ! XimpLCd lcd; { ! Locale locale = &lcd->locale; ! CodeSet *codeset; ! ParseInfo *parse_info; ! FontSetData font_data; ! int num; ! if (num = locale->fontset_data_num) { ! for (font_data = locale->fontset_data; num-- > 0; font_data++) ! if (font_data->font_name) ! XFree(font_data->font_name); ! XFree(locale->fontset_data); } ! ! if (locale->mb_parse_table) ! XFree(locale->mb_parse_table); ! if (num = locale->mb_parse_list_num) { ! for (parse_info = locale->mb_parse_list; num-- > 0; parse_info++) { ! if ((*parse_info)->encoding) ! XFree((*parse_info)->encoding); ! XFree(*parse_info); ! } ! XFree(locale->mb_parse_list); } + + if (num = locale->codeset_num) { + for (codeset = locale->codeset_list; num-- > 0; codeset++) { + if ((*codeset)->charset_list) + XFree((*codeset)->charset_list); + } + XFree(locale->codeset_list); + } } + #ifdef X_NOT_STDC_ENV #ifndef toupper *** /tmp/d03322 Tue Mar 9 09:17:00 1993 --- mit/lib/X/Ximp/XIMProto.h Tue Mar 9 09:16:56 1993 *************** *** 1,7 **** ! /* $XConsortium: XIMProto.h,v 1.6 92/07/29 10:15:02 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, --- 1,8 ---- ! /* $XConsortium: XIMProto.h,v 1.7 92/10/19 19:23:05 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED + Copyright 1991, 1992 by Sun Microsystems, Inc. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, *************** *** 8,94 **** provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of FUJITSU LIMITED ! not be used in advertising or publicity pertaining to distribution ! of the software without specific, written prior permission. ! FUJITSU LIMITED makes no representations about the suitability of ! this software for any purpose. It is provided "as is" without ! express or implied warranty. ! FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, ! INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, ! IN NO EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT ! OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS ! OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Author: Takashi Fujiwara FUJITSU LIMITED fujiwara@a80.tech.yk.fujitsu.co.jp ! ******************************************************************/ /* Ximp implementation revision */ ! #define XIMP_REVISION "Ximp Revision 3.3" /* Ximp Protocol Version */ #define XIMP_PROTOCOL_VERSION "XIMP.3.5" /* Input Context ID */ typedef unsigned long ICID; ! /* ClientMessage No. */ /* client <=> frontend */ ! #define XIMP_KEYPRESS 1 ! /* client => frontend */ ! /* Base Protocol */ ! #define XIMP_CREATE 2 ! #define XIMP_DESTROY 3 ! #define XIMP_BEGIN 4 ! #define XIMP_END 5 ! #define XIMP_SETFOCUS 6 ! #define XIMP_UNSETFOCUS 7 ! #define XIMP_CHANGE 8 ! #define XIMP_MOVE 9 ! #define XIMP_RESET 10 ! #define XIMP_SETVALUE 11 ! #define XIMP_GETVALUE 12 ! ! /* Callback Protocol */ ! #define XIMP_PREEDITSTART_RETURN 20 ! #define XIMP_PREEDITCARET_RETURN 21 ! ! /* frontend => client */ ! /* Base Protocol */ ! #define XIMP_CREATE_RETURN 2 ! #define XIMP_CONVERSION_BEGIN 30 ! #define XIMP_PROCESS_BEGIN 30 ! #define XIMP_CONVERSION_END 31 ! #define XIMP_PROCESS_END 31 ! #define XIMP_READPROP 32 ! #define XIMP_GETVALUE_RETURN 33 ! #define XIMP_RESET_RETURN 34 ! ! /* Callback Protocol */ ! #define XIMP_GEOMETRY 40 ! #define XIMP_PREEDITSTART 41 ! #define XIMP_PREEDITDONE 42 ! #define XIMP_PREEDITDRAW 43 ! #define XIMP_PREEDITDRAW_CM 44 ! #define XIMP_PREEDITCARET 45 ! #define XIMP_STATUSSTART 46 ! #define XIMP_STATUSDONE 47 ! #define XIMP_STATUSDRAW 48 ! #define XIMP_STATUSDRAW_CM 49 ! #define XIMP_PREEDITDRAW_TINY 50 ! /* Extension Protocol */ ! #define XIMP_EXTENSION 90 ! /* frontend = ERROR => client */ ! #define XIMP_ERROR 99 /* Error Notify from IM Server */ /* Detail Error Number */ #define XIMP_NoError 0 /* No Error */ --- 9,189 ---- provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of FUJITSU LIMITED ! and Sun Microsystems, Inc.not be used in advertising or publicity ! pertaining to distribution of the software without specific, written ! prior permission. FUJITSU LIMITED and Sun Microsystems, Inc. makes no ! representations about the suitability of this software for any purpose. ! It is provided "as is" without express or implied warranty. ! FUJITSU LIMITED AND SUN MICROSYSTEMS, INC DISCLAIM ALL WARRANTIES WITH ! REGARD TO THIS SOFTWARE,INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY ! AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, ! INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ! LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Author: Takashi Fujiwara FUJITSU LIMITED fujiwara@a80.tech.yk.fujitsu.co.jp ! Hideki Hiura Sun Microsystems, Inc. ! hhiura@Sun.COM ******************************************************************/ /* Ximp implementation revision */ ! #define XIMP_REVISION "Ximp Revision 3.4" /* Ximp Protocol Version */ + #ifdef XIMP_40 + #define XIMP_PROTOCOL_VERSION "XIMP.4.0" + #else #define XIMP_PROTOCOL_VERSION "XIMP.3.5" + #endif /* XIMP_40 */ + /* Ximp Protocol Version Number */ + #ifdef XIMP_40 + #define XIMP_VERSION_NUMBER 40 + #endif /* XIMP_40 */ + /* Input Context ID */ typedef unsigned long ICID; ! /* ClientMessage No. Ximp 4.0 */ /* client <=> frontend */ ! #define XIMP_KEYRELEASE4 100 ! #define XIMP_KEYPRESS4 101 ! /* client ==> frontend * Base Protocol */ ! #define XIMP_CREATE4 102 ! #define XIMP_DESTROY4 103 ! #define XIMP_REG_KEY_PRESSED4 104 ! #define XIMP_SETFOCUS4 105 ! #define XIMP_UNSETFOCUS4 106 ! #define XIMP_CLIENT_WINDOW4 107 ! #define XIMP_FOCUS_WINDOW4 108 ! #define XIMP_MOVE4 109 ! #define XIMP_RESET4 110 ! #define XIMP_SETVALUE4 111 ! #define XIMP_GETVALUE4 112 ! /* * Callback Protocol */ ! #define XIMP_PREEDITSTART_RETURN4 120 ! #define XIMP_PREEDITCARET_RETURN4 121 ! /* client <== frontend * Base Protocol */ ! #define XIMP_SPROC_STARTED4 130 ! #define XIMP_SPROC_STOPPED4 131 ! #define XIMP_READPROP4 132 ! #define XIMP_CLIENT_WINDOW_RETURN4 133 ! #define XIMP_FOCUS_WINDOW_RETURN4 134 ! #define XIMP_GETVALUE_RETURN4 135 ! #define XIMP_RESET_RETURN4 136 ! #define XIMP_CREATE_RETURN4 137 ! #define XIMP_KEYPRESS_RETURN4 138 ! #define XIMP_KEYRELEASE_RETURN4 139 ! /* * Callback Protocol */ ! #define XIMP_GEOMETRY4 140 ! #define XIMP_PREEDITSTART4 150 ! #define XIMP_PREEDITDONE4 151 ! #define XIMP_PREEDITDRAW4 152 ! #define XIMP_PREEDITDRAW_CM4 153 ! #define XIMP_PREEDITDRAW_CM_TINY4 154 ! #define XIMP_PREEDITDRAW_CM_FEEDBACK4 155 ! #define XIMP_PREEDITCARET4 156 ! #define XIMP_STATUSSTART4 160 ! #define XIMP_STATUSDONE4 161 ! #define XIMP_STATUSDRAW4 162 ! #define XIMP_STATUSDRAW_CM4 163 ! /* client => IM Server for frontend method */ ! #define XIMP_EVENTMASK_NOTIFY4 200 ! /* client <== frontend for frontend method */ ! #define XIMP_EVENTMASK_NOTIFY_RETURN4 201 ! /* Extension Protocol */ ! #define XIMP_EXTENSION4 500 ! /* client <== frontend * Error Protocol */ ! #define XIMP_ERROR4 999 ! /* ClientMessage No. Ximp 3.5 */ ! /* client <=> frontend */ ! #define XIMP_KEYPRESS3 1 ! /* client ==> frontend * Base Protocol */ ! #define XIMP_CREATE3 2 ! #define XIMP_DESTROY3 3 ! #define XIMP_BEGIN3 4 ! #define XIMP_END3 5 ! #define XIMP_SETFOCUS3 6 ! #define XIMP_UNSETFOCUS3 7 ! #define XIMP_CHANGE3 8 ! #define XIMP_MOVE3 9 ! #define XIMP_RESET3 10 ! #define XIMP_SETVALUE3 11 ! #define XIMP_GETVALUE3 12 ! /* * Callback Protocol */ ! #define XIMP_PREEDITSTART_RETURN3 20 ! #define XIMP_PREEDITCARET_RETURN3 21 ! /* client <== frontend * Base Protocol */ ! #define XIMP_CREATE_RETURN3 2 ! #define XIMP_CONVERSION_BEGIN3 30 ! #define XIMP_PROCESS_BEGIN3 30 ! #define XIMP_CONVERSION_END3 31 ! #define XIMP_PROCESS_END3 31 ! #define XIMP_READPROP3 32 ! #define XIMP_GETVALUE_RETURN3 33 ! #define XIMP_RESET_RETURN3 34 ! /* * Callback Protocol */ ! #define XIMP_GEOMETRY3 40 ! #define XIMP_PREEDITSTART3 41 ! #define XIMP_PREEDITDONE3 42 ! #define XIMP_PREEDITDRAW3 43 ! #define XIMP_PREEDITDRAW_CM3 44 ! #define XIMP_PREEDITCARET3 45 ! #define XIMP_STATUSSTART3 46 ! #define XIMP_STATUSDONE3 47 ! #define XIMP_STATUSDRAW3 48 ! #define XIMP_STATUSDRAW_CM3 49 ! #define XIMP_PREEDITDRAW_TINY3 50 /* Extension Protocol */ ! #define XIMP_EXTENSION3 90 ! /* client <== frontend * Error Protocol */ ! #define XIMP_ERROR3 99 ! /* For Backward Compatibility */ ! #ifndef XIMP_40 ! #define XIMP_KEYPRESS XIMP_KEYPRESS3 ! #define XIMP_CREATE XIMP_CREATE3 ! #define XIMP_DESTROY XIMP_DESTROY3 ! #define XIMP_BEGIN XIMP_BEGIN3 ! #define XIMP_END XIMP_END3 ! #define XIMP_SETFOCUS XIMP_SETFOCUS3 ! #define XIMP_UNSETFOCUS XIMP_UNSETFOCUS3 ! #define XIMP_CHANGE XIMP_CHANGE3 ! #define XIMP_MOVE XIMP_MOVE3 ! #define XIMP_RESET XIMP_RESET3 ! #define XIMP_SETVALUE XIMP_SETVALUE3 ! #define XIMP_GETVALUE XIMP_GETVALUE3 ! #define XIMP_PREEDITSTART_RETURN XIMP_PREEDITSTART_RETURN3 ! #define XIMP_PREEDITCARET_RETURN XIMP_PREEDITCARET_RETURN3 ! #define XIMP_CREATE_RETURN XIMP_CREATE_RETURN3 ! #define XIMP_CONVERSION_BEGIN XIMP_CONVERSION_BEGIN3 ! #define XIMP_PROCESS_BEGIN XIMP_PROCESS_BEGIN3 ! #define XIMP_CONVERSION_END XIMP_CONVERSION_END3 ! #define XIMP_PROCESS_END XIMP_PROCESS_END3 ! #define XIMP_READPROP XIMP_READPROP3 ! #define XIMP_GETVALUE_RETURN XIMP_GETVALUE_RETURN3 ! #define XIMP_RESET_RETURN XIMP_RESET_RETURN3 ! #define XIMP_GEOMETRY XIMP_GEOMETRY3 ! #define XIMP_PREEDITSTART XIMP_PREEDITSTART3 ! #define XIMP_PREEDITDONE XIMP_PREEDITDONE3 ! #define XIMP_PREEDITDRAW XIMP_PREEDITDRAW3 ! #define XIMP_PREEDITDRAW_CM XIMP_PREEDITDRAW_CM3 ! #define XIMP_PREEDITCARET XIMP_PREEDITCARET3 ! #define XIMP_STATUSSTART XIMP_STATUSSTART3 ! #define XIMP_STATUSDONE XIMP_STATUSDONE3 ! #define XIMP_STATUSDRAW XIMP_STATUSDRAW3 ! #define XIMP_STATUSDRAW_CM XIMP_STATUSDRAW_CM3 ! #define XIMP_PREEDITDRAW_TINY XIMP_PREEDITDRAW_TINY3 ! #define XIMP_EXTENSION XIMP_EXTENSION3 ! #define XIMP_ERROR XIMP_ERROR3 ! #endif /* !XIMP_40 */ + /* Error Notify from IM Server */ /* Detail Error Number */ #define XIMP_NoError 0 /* No Error */ *************** *** 113,126 **** #define _XIMP_BASE "_XIMP_" /* Root Window _XIP_ */ /* IMS Window Property Name */ ! #define _XIMP_VERSION "_XIMP_VERSION" ! #define _XIMP_STYLE "_XIMP_STYLE" ! #define _XIMP_KEYS "_XIMP_KEYS" ! #define _XIMP_SERVERNAME "_XIMP_SERVERNAME" ! #define _XIMP_SERVERVERSION "_XIMP_SERVERVERSION" ! #define _XIMP_EXTENSIONS "_XIMP_EXTENSIONS" ! #define _XIMP_PREEDITMAXSIZE "_XIMP_PREEDITMAXSIZE" ! #define _XIMP_VENDORNAME "_XIMP_VENDORNAME" /* Client Window Property Name */ #define _XIMP_LIBVERSION "_XIMP_VERSION" --- 208,224 ---- #define _XIMP_BASE "_XIMP_" /* Root Window _XIP_ */ /* IMS Window Property Name */ ! #define _XIMP_VERSION "_XIMP_VERSION" ! #define _XIMP_STYLE "_XIMP_STYLE" ! #define _XIMP_SPROC_STARTED_KEYS "_XIMP_SPROC_STARTED_KEYS" ! #define _XIMP_SPROC_STOPPED_KEYS "_XIMP_SPROC_STOPPED_KEYS" ! #define _XIMP_KEYS "_XIMP_KEYS" ! #define _XIMP_SERVERNAME "_XIMP_SERVERNAME" ! #define _XIMP_SERVERVERSION "_XIMP_SERVERVERSION" ! #define _XIMP_EXTENSIONS "_XIMP_EXTENSIONS" ! #define _XIMP_PREEDITMAXSIZE "_XIMP_PREEDITMAXSIZE" ! #define _XIMP_VENDORNAME "_XIMP_VENDORNAME" ! #define _XIMP_TYPE "_XIMP_TYPE" /* Client Window Property Name */ #define _XIMP_LIBVERSION "_XIMP_VERSION" *************** *** 155,187 **** #define LOOKUP_CHOICES_DRAW_REQ 5 #define LOOKUP_CHOICES_DONE_REQ 6 /* mask (XIMP_CREATE, XIMP_SETVALUE, XIMP_GETVALUE) */ ! #define XIMP_FOCUS_WIN_MASK (1L << 0) ! #define XIMP_PRE_AREA_MASK (1L << 1) ! #define XIMP_PRE_FG_MASK (1L << 2) ! #define XIMP_PRE_BG_MASK (1L << 3) ! #define XIMP_PRE_COLORMAP_MASK (1L << 4) ! #define XIMP_PRE_BGPIXMAP_MASK (1L << 5) ! #define XIMP_PRE_LINESP_MASK (1L << 6) ! #define XIMP_PRE_CURSOR_MASK (1L << 7) ! #define XIMP_PRE_AREANEED_MASK (1L << 8) ! #define XIMP_PRE_SPOTL_MASK (1L << 9) ! #define XIMP_STS_AREA_MASK (1L << 10) ! #define XIMP_STS_FG_MASK (1L << 11) ! #define XIMP_STS_BG_MASK (1L << 12) ! #define XIMP_STS_COLORMAP_MASK (1L << 13) ! #define XIMP_STS_BGPIXMAP_MASK (1L << 14) ! #define XIMP_STS_LINESP_MASK (1L << 15) ! #define XIMP_STS_CURSOR_MASK (1L << 16) ! #define XIMP_STS_AREANEED_MASK (1L << 17) ! #define XIMP_STS_WINDOW_MASK (1L << 18) ! #define XIMP_PRE_FONT_MASK (1L << 19) ! #define XIMP_STS_FONT_MASK (1L << 20) ! /* FRONTEND or BACKEND MODE */ ! #define XIMP_FRONTEND 0 ! #define XIMP_BACKEND 1 /* XIMP_PREEDITDRAW_CM status value * post Ximp 3.4 protocol maybe compliant. * XIMP status flag will may contain the supplementary infomations to --- 253,357 ---- #define LOOKUP_CHOICES_DRAW_REQ 5 #define LOOKUP_CHOICES_DONE_REQ 6 + /* mask (XIMP_CREATE, XIMP_SETVALUE, XIMP_GETVALUE) */ ! /* Ximp 4.0 */ ! #define XIMP_FOCUS_WIN_MASK4 (1L << 0) ! #define XIMP_PRE_AREA_MASK4 (1L << 1) ! #define XIMP_PRE_AREANEED_MASK4 (1L << 2) ! #define XIMP_PRE_COLORMAP_MASK4 (1L << 3) ! #define XIMP_PRE_STD_COLORMAP_MASK4 (1L << 4) ! #define XIMP_PRE_FG_MASK4 (1L << 5) ! #define XIMP_PRE_BG_MASK4 (1L << 6) ! #define XIMP_PRE_BGPIXMAP_MASK4 (1L << 7) ! #define XIMP_PRE_LINESP_MASK4 (1L << 8) ! #define XIMP_PRE_CURSOR_MASK4 (1L << 9) ! #define XIMP_PRE_SPOTL_MASK4 (1L << 10) ! #define XIMP_STS_AREA_MASK4 (1L << 11) ! #define XIMP_STS_AREANEED_MASK4 (1L << 12) ! #define XIMP_STS_COLORMAP_MASK4 (1L << 13) ! #define XIMP_STS_STD_COLORMAP_MASK4 (1L << 14) ! #define XIMP_STS_FG_MASK4 (1L << 15) ! #define XIMP_STS_BG_MASK4 (1L << 16) ! #define XIMP_STS_BGPIXMAP_MASK4 (1L << 17) ! #define XIMP_STS_LINESP_MASK4 (1L << 18) ! #define XIMP_STS_CURSOR_MASK4 (1L << 19) ! #define XIMP_STS_WINDOW_MASK4 (1L << 20) ! #define XIMP_PRE_FONT_MASK4 (1L << 21) ! #define XIMP_STS_FONT_MASK4 (1L << 22) ! #define XIMP_SERVERTYPE_MASK4 (1L << 23) ! /* Ximp 3.5 */ ! #define XIMP_FOCUS_WIN_MASK3 (1L << 0) ! #define XIMP_PRE_AREA_MASK3 (1L << 1) ! #define XIMP_PRE_FG_MASK3 (1L << 2) ! #define XIMP_PRE_BG_MASK3 (1L << 3) ! #define XIMP_PRE_COLORMAP_MASK3 (1L << 4) ! #define XIMP_PRE_BGPIXMAP_MASK3 (1L << 5) ! #define XIMP_PRE_LINESP_MASK3 (1L << 6) ! #define XIMP_PRE_CURSOR_MASK3 (1L << 7) ! #define XIMP_PRE_AREANEED_MASK3 (1L << 8) ! #define XIMP_PRE_SPOTL_MASK3 (1L << 9) ! #define XIMP_STS_AREA_MASK3 (1L << 10) ! #define XIMP_STS_FG_MASK3 (1L << 11) ! #define XIMP_STS_BG_MASK3 (1L << 12) ! #define XIMP_STS_COLORMAP_MASK3 (1L << 13) ! #define XIMP_STS_BGPIXMAP_MASK3 (1L << 14) ! #define XIMP_STS_LINESP_MASK3 (1L << 15) ! #define XIMP_STS_CURSOR_MASK3 (1L << 16) ! #define XIMP_STS_AREANEED_MASK3 (1L << 17) ! #define XIMP_STS_WINDOW_MASK3 (1L << 18) ! #define XIMP_PRE_FONT_MASK3 (1L << 19) ! #define XIMP_STS_FONT_MASK3 (1L << 20) + /* mask (For Backward Compatibility) */ + #ifndef XIMP_40 + #define XIMP_FOCUS_WIN_MASK XIMP_FOCUS_WIN_MASK3 + #define XIMP_PRE_AREA_MASK XIMP_PRE_AREA_MASK3 + #define XIMP_PRE_FG_MASK XIMP_PRE_FG_MASK3 + #define XIMP_PRE_BG_MASK XIMP_PRE_BG_MASK3 + #define XIMP_PRE_COLORMAP_MASK XIMP_PRE_COLORMAP_MASK3 + #define XIMP_PRE_BGPIXMAP_MASK XIMP_PRE_BGPIXMAP_MASK3 + #define XIMP_PRE_LINESP_MASK XIMP_PRE_LINESP_MASK3 + #define XIMP_PRE_CURSOR_MASK XIMP_PRE_CURSOR_MASK3 + #define XIMP_PRE_AREANEED_MASK XIMP_PRE_AREANEED_MASK3 + #define XIMP_PRE_SPOTL_MASK XIMP_PRE_SPOTL_MASK3 + #define XIMP_STS_AREA_MASK XIMP_STS_AREA_MASK3 + #define XIMP_STS_FG_MASK XIMP_STS_FG_MASK3 + #define XIMP_STS_BG_MASK XIMP_STS_BG_MASK3 + #define XIMP_STS_COLORMAP_MASK XIMP_STS_COLORMAP_MASK3 + #define XIMP_STS_BGPIXMAP_MASK XIMP_STS_BGPIXMAP_MASK3 + #define XIMP_STS_LINESP_MASK XIMP_STS_LINESP_MASK3 + #define XIMP_STS_CURSOR_MASK XIMP_STS_CURSOR_MASK3 + #define XIMP_STS_AREANEED_MASK XIMP_STS_AREANEED_MASK3 + #define XIMP_STS_WINDOW_MASK XIMP_STS_WINDOW_MASK3 + #define XIMP_PRE_FONT_MASK XIMP_PRE_FONT_MASK3 + #define XIMP_STS_FONT_MASK XIMP_STS_FONT_MASK3 + #endif /* !XIMP_40 */ + + /* MODE(FRONTEND or BACKEND), TYPE(Type1,2,3) and SYNC/ASYNC */ + #define XIMP_FRONTEND4 (1L << 0) + #define XIMP_BACKEND4 (1L << 1) + #define XIMP_TYPE1 (1L << 2) + #define XIMP_TYPE2 (1L << 3) + #define XIMP_TYPE3 (1L << 4) + #define XIMP_SYNC (1L << 5) + #define XIMP_FE_TYPE1 (XIMP_FRONTEND4 | XIMP_TYPE1) + #define XIMP_FE_TYPE2 (XIMP_FRONTEND4 | XIMP_TYPE2) + #define XIMP_FE_TYPE3 (XIMP_FRONTEND4 | XIMP_TYPE3) + #define XIMP_BE_TYPE1 (XIMP_BACKEND4 | XIMP_TYPE1) + #define XIMP_BE_TYPE2 (XIMP_BACKEND4 | XIMP_TYPE2) + #define XIMP_SYNC_BE_TYPE1 (XIMP_SYNC | XIMP_BE_TYPE1) + #define XIMP_SYNC_BE_TYPE2 (XIMP_SYNC | XIMP_BE_TYPE2) + + /* MODE(FRONTEND or BACKEND) For Backward Compatibility */ + #define XIMP_FRONTEND_BC_MASK (1L << 0) + #define XIMP_BACKEND_BC_MASK (1L << 1) + + /* mask (For Backward Compatibility) */ + #define XIMP_FRONTEND 0 + #define XIMP_BACKEND 1 + /* XIMP_PREEDITDRAW_CM status value * post Ximp 3.4 protocol maybe compliant. * XIMP status flag will may contain the supplementary infomations to *************** *** 213,224 **** unsigned long modifier; unsigned long modifier_mask; KeySym keysym; ! } Ximp_Key; typedef struct { unsigned short count_keys; Ximp_Key *keys_list; ! } Ximp_KeyList; typedef struct _Ximp_Area { long x; --- 383,394 ---- unsigned long modifier; unsigned long modifier_mask; KeySym keysym; ! } Ximp_Key; typedef struct { unsigned short count_keys; Ximp_Key *keys_list; ! } Ximp_KeyList; typedef struct _Ximp_Area { long x; *************** *** 225,273 **** long y; long width; long height; ! } Ximp_AreaRec; typedef struct _Ximp_Point { long x; long y; ! } Ximp_PointRec; typedef struct _Ximp_Size { long width; long height; ! } Ximp_SizeRec; /* kana-kanji conversion window attributes */ ! #define XIMP_PREEDIT_MAX_LONG 14 ! #define XIMP_PREEDIT_MAX_CHAR 56 ! typedef struct _Ximp_Preedit { Ximp_AreaRec Area; unsigned long Foreground; unsigned long Background; - Colormap Colormap; Pixmap Bg_Pixmap; long LineSpacing; Cursor Cursor; ! Ximp_SizeRec AreaNeeded; ! Ximp_PointRec SpotLocation; ! } Ximp_PreeditPropRec; ! #define XIMP_STATUS_MAX_LONG 13 ! #define XIMP_STATUS_MAX_CHAR 52 ! typedef struct _Ximp_Status { Ximp_AreaRec Area; unsigned long Foreground; unsigned long Background; - Colormap Colormap; Pixmap Bg_Pixmap; long LineSpacing; Cursor Cursor; - Ximp_SizeRec AreaNeeded; Window window; ! } Ximp_StatusPropRec; /* for CallBack */ typedef struct _Ximp_PreeditDrawDataPropRec { --- 395,513 ---- long y; long width; long height; ! } Ximp_AreaRec; typedef struct _Ximp_Point { long x; long y; ! } Ximp_PointRec; typedef struct _Ximp_Size { long width; long height; ! } Ximp_SizeRec; /* kana-kanji conversion window attributes */ ! #ifdef XIMP_40 ! #define XIMP_PREEDIT_MAX_LONG4 15 ! #define XIMP_PREEDIT_MAX_CHAR4 60 ! ! typedef struct _Ximp_Preedit4 { Ximp_AreaRec Area; + Ximp_SizeRec AreaNeeded; + Ximp_PointRec SpotLocation; + Colormap Colormap; + Atom StdColormap; unsigned long Foreground; unsigned long Background; Pixmap Bg_Pixmap; long LineSpacing; Cursor Cursor; ! } Ximp_PreeditPropRec4; ! #define XIMP_PREEDIT_MAX_LONG3 14 ! #define XIMP_PREEDIT_MAX_CHAR3 56 ! typedef struct _Ximp_Preedit3 { ! Ximp_AreaRec Area; ! unsigned long Foreground; ! unsigned long Background; ! Colormap Colormap; ! Pixmap Bg_Pixmap; ! long LineSpacing; ! Cursor Cursor; ! Ximp_SizeRec AreaNeeded; ! Ximp_PointRec SpotLocation; ! } Ximp_PreeditPropRec3; ! ! #define XIMP_STATUS_MAX_LONG4 14 ! #define XIMP_STATUS_MAX_CHAR4 56 ! #define XIMP_STATUS_MAX_LONG4 14 ! #define XIMP_STATUS_MAX_CHAR4 56 ! ! typedef struct _Ximp_Status4 { Ximp_AreaRec Area; + Ximp_SizeRec AreaNeeded; + Colormap Colormap; + Atom StdColormap; unsigned long Foreground; unsigned long Background; Pixmap Bg_Pixmap; long LineSpacing; Cursor Cursor; Window window; ! } Ximp_StatusPropRec4; ! ! #define XIMP_STATUS_MAX_LONG3 13 ! #define XIMP_STATUS_MAX_CHAR3 52 ! ! typedef struct _Ximp_Status3 { ! Ximp_AreaRec Area; ! unsigned long Foreground; ! unsigned long Background; ! Colormap Colormap; ! Pixmap Bg_Pixmap; ! long LineSpacing; ! Cursor Cursor; ! Ximp_SizeRec AreaNeeded; ! Window window; ! } Ximp_StatusPropRec3; ! ! #else /* XIMP_40 */ /* For Backward Compatibility */ ! ! #define XIMP_PREEDIT_MAX_LONG 14 ! #define XIMP_PREEDIT_MAX_CHAR 56 ! ! typedef struct _Ximp_Preedit { ! Ximp_AreaRec Area; ! unsigned long Foreground; ! unsigned long Background; ! Colormap Colormap; ! Pixmap Bg_Pixmap; ! long LineSpacing; ! Cursor Cursor; ! Ximp_SizeRec AreaNeeded; ! Ximp_PointRec SpotLocation; ! } Ximp_PreeditPropRec; ! ! #define XIMP_STATUS_MAX_LONG 13 ! #define XIMP_STATUS_MAX_CHAR 52 ! ! typedef struct _Ximp_Status { ! Ximp_AreaRec Area; ! unsigned long Foreground; ! unsigned long Background; ! Colormap Colormap; ! Pixmap Bg_Pixmap; ! long LineSpacing; ! Cursor Cursor; ! Ximp_SizeRec AreaNeeded; ! Window window; ! } Ximp_StatusPropRec; ! ! #endif /* XIMP_40 */ /* for CallBack */ typedef struct _Ximp_PreeditDrawDataPropRec { *** /tmp/d03344 Tue Mar 9 09:17:13 1993 --- mit/lib/X/Ximp/XimpCallbk.c Tue Mar 9 09:17:10 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpCallbk.c,v 1.6 92/07/29 10:15:36 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by Fuji Xerox Co.,Ltd. --- 1,4 ---- ! /* $XConsortium: XimpCallbk.c,v 1.7 92/10/19 19:23:51 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by Fuji Xerox Co.,Ltd. *************** *** 29,37 **** CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Auther: Kazunori Nishihara, Fuji Xerox Co.,Ltd. Takashi Fujiwara FUJITSU LIMITED Hideki Hiura Sun Microsystems, Inc. ! Makoto Wakamatsu Sony Corporation ******************************************************************/ #define NEED_EVENTS --- 29,39 ---- CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Auther: Kazunori Nishihara, Fuji Xerox Co.,Ltd. + kaz@ssdev.ksp.fujixerox.co.jp Takashi Fujiwara FUJITSU LIMITED + fujiwara@a80.tech.yk.fujitsu.co.jp Hideki Hiura Sun Microsystems, Inc. ! hhiura@Sun.COM ******************************************************************/ #define NEED_EVENTS *************** *** 41,49 **** #include "Ximplc.h" - #define XIMP_MAXBUF 256 extern void _Ximp_IM_SendMessage(); void _Ximp_CallGeometryCallback(xic, event) --- 43,51 ---- #include "Ximplc.h" extern void _Ximp_IM_SendMessage(); + extern Bool _Ximp_CMPredicate8(); void _Ximp_CallGeometryCallback(xic, event) *************** *** 59,79 **** } void ! _Ximp_CallPreeditStartCallback(xic, event) ! Ximp_XIC xic; XClientMessageEvent *event; { register XIMCallback *cb; int data; ! cb = &xic->core.preedit_attr.callbacks.start; if (cb->callback) { ! data = (*(int (*) ()) cb->callback) (xic, cb->client_data, NULL); ! } else { data = -1; } ! _Ximp_IM_SendMessage(xic, XIMP_PREEDITSTART_RETURN, data, NULL, NULL); } void --- 61,81 ---- } void ! _Ximp_CallPreeditStartCallback(ic, event) ! Ximp_XIC ic; XClientMessageEvent *event; { register XIMCallback *cb; int data; ! cb = &ic->core.preedit_attr.callbacks.start; if (cb->callback) { ! data = (*(int (*) ()) cb->callback) (ic, cb->client_data, NULL); ! ic->ximp_icpart->cbstatus |= XIMPCBPREEDITACTIVE ; } else { data = -1; } ! _Ximp_IM_SendMessage(ic, XIMP_PREEDITSTART_RETURN(ic), data, NULL, NULL); } void *************** *** 86,91 **** --- 88,94 ---- cb = &xic->core.preedit_attr.callbacks.done; if (cb->callback) { (*cb->callback) (xic, cb->client_data, NULL); + xic->ximp_icpart->cbstatus &= ~XIMPCBPREEDITACTIVE ; } } *************** *** 167,193 **** /* * wide_char is union with multi_byte. */ ! cbtext.string.wide_char = (wchar_t *) Xmalloc(ctlen * sizeof(wchar_t)); ! bzero(cbtext.string.wide_char, sizeof(wchar_t) * ctlen); ! ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { ! cbtext.encoding_is_wchar = True; ! if (_Ximp_cttowcs(xic->core.im->core.lcd, ctext, ! nitems, cbtext.string.wide_char, ! &length, NULL) < 0) { ! length = 0; } - } else { - cbtext.encoding_is_wchar = False; - if (_Ximp_cttombs(xic->core.im->core.lcd, ctext, - nitems, cbtext.string.multi_byte, - &length, NULL) < 0) { - length = 0; - } } ! if (cbtext.feedback == NULL) { ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { if (!(cbtext.length = length)) { if (cbtext.string.wide_char) Xfree(cbtext.string.wide_char); --- 170,200 ---- /* * wide_char is union with multi_byte. */ ! ! if( (cbtext.string.wide_char = (wchar_t *) Xmalloc(ctlen * sizeof(wchar_t))) == NULL ) { ! length = 0; ! } ! else { ! bzero(cbtext.string.wide_char, sizeof(wchar_t) * ctlen); ! if (IS_USE_WCHAR(xic)) { ! cbtext.encoding_is_wchar = True; ! if (_Ximp_cttowcs(xic->core.im->core.lcd, ctext, ! nitems, cbtext.string.wide_char, ! &length, NULL) < 0) { ! length = 0; ! } ! } else { ! cbtext.encoding_is_wchar = False; ! if (_Ximp_cttombs(xic->core.im->core.lcd, ctext, ! nitems, cbtext.string.multi_byte, ! &length, NULL) < 0) { ! length = 0; ! } } } ! if (cbtext.feedback == NULL) { ! if (IS_USE_WCHAR(xic)) { if (!(cbtext.length = length)) { if (cbtext.string.wide_char) Xfree(cbtext.string.wide_char); *************** *** 240,249 **** } else { CallData.text = &cbtext; } - (*cb->callback) (xic, cb->client_data, &CallData); ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { if (cbtext.string.wide_char) { Xfree((XPointer) (cbtext.string.wide_char)); } --- 247,255 ---- } else { CallData.text = &cbtext; } (*cb->callback) (xic, cb->client_data, &CallData); ! if (IS_USE_WCHAR(xic)) { if (cbtext.string.wide_char) { Xfree((XPointer) (cbtext.string.wide_char)); } *************** *** 267,307 **** } } - static Bool - _Ximp_DCMPredicate( d, ev, arg0 ) - Display *d; - XEvent *ev; - XPointer arg0; - { - XimpCMPredicateArg arg = (XimpCMPredicateArg)arg0; - ICID icid; - int n; - - if( ev->type == ClientMessage ) { - if( ev->xclient.message_type == arg->type ) { - if( ev->xclient.format == 8 ) { - for( icid = 0, n = 0; n < 4; n++ ) { - icid <<= 8; - icid += ev->xclient.data.b[n]; - } - if( icid == arg->icid ) - return( True ); - } - else if( ev->xclient.format == 32 && - ev->xclient.data.l[0] == XIMP_ERROR && - ev->xclient.data.l[1] == arg->icid ) { - return( True ); - } - } - } - else if( ev->type == DestroyNotify ) { - if( ev->xdestroywindow.window == arg->owner ) { - return( True ); - } - } - } - - void _Ximp_CallPreeditDrawCallback2(xic, event) Ximp_XIC xic; --- 273,278 ---- *************** *** 314,325 **** int length; XEvent ev; short pdcbStatus = (short) ((event->data.l[2] >> 16) & 0xffffl); ! int ctlen; Atom type; int format; unsigned long nitems, after; XimpCMPredicateArgRec Arg; bzero(&CallData, sizeof(XIMPreeditDrawCallbackStruct)); bzero(&cbtext, sizeof(XIMText)); --- 285,302 ---- int length; XEvent ev; short pdcbStatus = (short) ((event->data.l[2] >> 16) & 0xffffl); ! int ctlen = 0; Atom type; int format; unsigned long nitems, after; + unsigned char *tmp; /* for multiple ClientMessage */ + unsigned char *tmpp; /* for multiple ClientMessage */ + int work; + int i; XimpCMPredicateArgRec Arg; + tmpp = tmp = NULL; + bzero(&CallData, sizeof(XIMPreeditDrawCallbackStruct)); bzero(&cbtext, sizeof(XIMText)); *************** *** 357,363 **** if (!(pdcbStatus & XIMP_PDCBSTATUS_FEEDBACKS_VIA_PROP)) { /* error */ } else { ! /* * Not implemented yet. */ if (XGetWindowProperty(xic->core.im->core.display, --- 334,340 ---- if (!(pdcbStatus & XIMP_PDCBSTATUS_FEEDBACKS_VIA_PROP)) { /* error */ } else { ! /* * Not implemented yet. */ if (XGetWindowProperty(xic->core.im->core.display, *************** *** 372,439 **** } } } else { /* if preedit text is exist */ ! /* ! * Following Client message must be the preedit string. ! */ ! Arg.type = ((Ximp_XIM)xic->core.im)->ximp_impart->improtocol_id; ! Arg.owner = ((Ximp_XIM)xic->core.im)->ximp_impart->fe_window; ! Arg.icid = xic->ximp_icpart->icid; ! if( !_XimpIfEvent( xic, &ev, _Ximp_DCMPredicate, (XPointer)&Arg ) ) ! return; ! ctlen = ev.xclient.data.b[4]; length = ctlen * XIMP_MB_CUR_MAX(xic->core.im->core.lcd); ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { ! cbtext.string.wide_char = (wchar_t *) Xmalloc((length + 1) * sizeof(wchar_t)); ! bzero(cbtext.string.wide_char, sizeof(wchar_t) * (length + 1)); ! cbtext.encoding_is_wchar = True; ! if (_Ximp_cttowcs(xic->core.im->core.lcd, ! &ev.xclient.data.b[5], ev.xclient.data.b[4], ! cbtext.string.wide_char, ! &length, NULL) < 0) { length = 0; } cbtext.length = length; } else { ! cbtext.string.multi_byte = Xmalloc(length + 1); ! bzero(cbtext.string.multi_byte, length + 1); ! cbtext.encoding_is_wchar = False; ! if (_Ximp_cttombs(xic->core.im->core.lcd, ! &ev.xclient.data.b[5], ev.xclient.data.b[4], ! cbtext.string.multi_byte, ! &length, NULL) < 0) { length = 0; } ! ! if ((length = ! _Ximp_mbs_charlen(xic->core.im->core.lcd, cbtext.string.multi_byte, length)) < 0) { ! length = 0 ; ! if (cbtext.string.multi_byte) ! Xfree(cbtext.string.multi_byte); ! cbtext.string.multi_byte = NULL; } cbtext.length = length; - } ! ! ! if (event->data.l[4] != -1) { ! int i; ! ! cbtext.feedback = (XIMFeedback *) Xmalloc(cbtext.length * sizeof(XIMFeedback)); ! for (i = 0; i < (int) cbtext.length; i++) { ! cbtext.feedback[i] = event->data.l[4]; ! } ! } else { cbtext.feedback = NULL; } - } (*cb->callback) (xic, cb->client_data, &CallData); ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { if (cbtext.string.wide_char) Xfree((XPointer) (cbtext.string.wide_char)); } else { --- 349,416 ---- } } } else { /* if preedit text is exist */ ! unsigned char *ct = NULL ; ! ctlen = _Ximp_CombineMultipleCM(xic, &ct); ! length = ctlen * XIMP_MB_CUR_MAX(xic->core.im->core.lcd); ! if (IS_USE_WCHAR(xic)) { ! if( (cbtext.string.wide_char = (wchar_t *) Xmalloc((length + 1) * sizeof(wchar_t))) == NULL ) { length = 0; } + else { + bzero(cbtext.string.wide_char, sizeof(wchar_t) * (length + 1)); + cbtext.encoding_is_wchar = True; + if (_Ximp_cttowcs(xic->core.im->core.lcd, + ct, ctlen, + cbtext.string.wide_char, + &length, NULL) < 0) { + length = 0; + } + } cbtext.length = length; } else { ! if( (cbtext.string.multi_byte = Xmalloc(length + 1)) == NULL ) { length = 0; } ! else { ! bzero(cbtext.string.multi_byte, length + 1); ! cbtext.encoding_is_wchar = False; ! if (_Ximp_cttombs(xic->core.im->core.lcd, ! ct, ctlen, ! cbtext.string.multi_byte, ! &length, NULL) < 0) { ! length = 0; ! } ! else if ((length = _Ximp_mbs_charlen(xic->core.im->core.lcd, cbtext.string.multi_byte, length)) < 0) { ! length = 0; ! } } cbtext.length = length; } ! if(pdcbStatus & XIMP_PDCBSTATUS_NOFEEDBACK) { cbtext.feedback = NULL; + } else if(pdcbStatus & XIMP_PDCBSTATUS_FEEDBACKS_VIA_PROP) { + if (XGetWindowProperty(xic->core.im->core.display, + ((Ximp_XIM) xic->core.im)->ximp_impart->fe_window, + event->data.l[4], 0, 4096, True, AnyPropertyType, + &type, &format, &nitems, &after, + (unsigned char **) &cbtext.feedback) == Success) { + cbtext.length = nitems; + } else { + cbtext.length = 0 ; + } + } else { + if( cbtext.feedback = (XIMFeedback *) Xmalloc(cbtext.length * sizeof(XIMFeedback)) ) + for (i = 0; i < (int) cbtext.length; i++) + cbtext.feedback[i] = event->data.l[4]; } } (*cb->callback) (xic, cb->client_data, &CallData); ! if (IS_USE_WCHAR(xic)) { if (cbtext.string.wide_char) Xfree((XPointer) (cbtext.string.wide_char)); } else { *************** *** 440,445 **** --- 417,424 ---- if (cbtext.string.multi_byte) Xfree((XPointer) (cbtext.string.multi_byte)); } + if(tmp) + Xfree((unsigned char *) tmp); if (cbtext.feedback) Xfree((XPointer) cbtext.feedback); } *************** *** 454,460 **** XIMPreeditDrawCallbackStruct CallData; XIMText cbtext; unsigned long text_data[2]; ! static wchar_t local_buf[16]; int length = 16; bzero(&CallData, sizeof(XIMPreeditDrawCallbackStruct)); --- 433,439 ---- XIMPreeditDrawCallbackStruct CallData; XIMText cbtext; unsigned long text_data[2]; ! static wchar_t local_buf[16] = {0}; /* rm bss data */ int length = 16; bzero(&CallData, sizeof(XIMPreeditDrawCallbackStruct)); *************** *** 485,491 **** text_data[1] = htonl(event->data.l[4]); if (cb->callback) { ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { cbtext.encoding_is_wchar = True; cbtext.string.wide_char = local_buf; if (_Ximp_cttowcs(xic->core.im->core.lcd, (char *)text_data, (event->data.l[2] & 0xffl), cbtext.string.wide_char, &length, NULL) >= 0) { --- 464,470 ---- text_data[1] = htonl(event->data.l[4]); if (cb->callback) { ! if (IS_USE_WCHAR(xic)) { cbtext.encoding_is_wchar = True; cbtext.string.wide_char = local_buf; if (_Ximp_cttowcs(xic->core.im->core.lcd, (char *)text_data, (event->data.l[2] & 0xffl), cbtext.string.wide_char, &length, NULL) >= 0) { *************** *** 504,511 **** } void ! _Ximp_CallPreeditCaretCallback(xic, event) ! Ximp_XIC xic; XClientMessageEvent *event; { register XIMCallback *cb; --- 483,490 ---- } void ! _Ximp_CallPreeditCaretCallback(ic, event) ! Ximp_XIC ic; XClientMessageEvent *event; { register XIMCallback *cb; *************** *** 513,527 **** #define ToXIMCaretStyle(x) ((XIMCaretStyle)(x)) #define ToXIMCaretDirection(x) ((XIMCaretDirection)(x)) ! cb = &xic->core.preedit_attr.callbacks.caret; if (cb->callback) { CallData.position = event->data.l[2]; CallData.direction = ToXIMCaretDirection(event->data.l[3]); CallData.style = ToXIMCaretStyle(event->data.l[4]); ! (*cb->callback) (xic, cb->client_data, &CallData); ! ! _Ximp_IM_SendMessage(xic, XIMP_PREEDITCARET_RETURN, ! CallData.position, NULL, NULL); } } --- 492,505 ---- #define ToXIMCaretStyle(x) ((XIMCaretStyle)(x)) #define ToXIMCaretDirection(x) ((XIMCaretDirection)(x)) ! cb = &ic->core.preedit_attr.callbacks.caret; if (cb->callback) { CallData.position = event->data.l[2]; CallData.direction = ToXIMCaretDirection(event->data.l[3]); CallData.style = ToXIMCaretStyle(event->data.l[4]); ! (*cb->callback) (ic, cb->client_data, &CallData); ! _Ximp_IM_SendMessage(ic, XIMP_PREEDITCARET_RETURN(ic), ! CallData.position, NULL, NULL); } } *************** *** 535,540 **** --- 513,519 ---- cb = &xic->core.status_attr.callbacks.start; if (cb->callback) { (*cb->callback) (xic, cb->client_data, NULL); + xic->ximp_icpart->cbstatus |= XIMPCBSTATUSACTIVE ; } } *************** *** 548,553 **** --- 527,533 ---- cb = &xic->core.status_attr.callbacks.done; if (cb->callback) { (*cb->callback) (xic, cb->client_data, NULL); + xic->ximp_icpart->cbstatus &= ~XIMPCBSTATUSACTIVE ; } } *************** *** 574,585 **** int format; unsigned long nitems, after; CallData.data.text = &cbtext; ! if (XGetWindowProperty(xic->core.im->core.display, ! ((Ximp_XIM) xic->core.im)->ximp_impart->fe_window, ! event->data.l[4], 0, 4096, True, AnyPropertyType, ! &type, &format, &nitems, &after, ! (unsigned char **) &cbtext.feedback) == Success) { ! cbtext.length = nitems; } else { cbtext.feedback = NULL; cbtext.length = 0; --- 554,570 ---- int format; unsigned long nitems, after; CallData.data.text = &cbtext; ! if (event->data.l[4]) { ! if (XGetWindowProperty(xic->core.im->core.display, ! ((Ximp_XIM) xic->core.im)->ximp_impart->fe_window, ! event->data.l[4], 0, 4096, True, AnyPropertyType, ! &type, &format, &nitems, &after, ! (unsigned char **) &cbtext.feedback) == Success) { ! cbtext.length = nitems; ! } else { ! cbtext.feedback = NULL; ! cbtext.length = 0; ! } } else { cbtext.feedback = NULL; cbtext.length = 0; *************** *** 589,624 **** event->data.l[3], 0, 4096, True, AnyPropertyType, &type, &format, &nitems, &after, (unsigned char **) &text) == Success) { ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { ! cbtext.string.wide_char = (wchar_t *) Xmalloc((XIMP_MAXBUF + 1) * sizeof(wchar_t)); ! bzero(cbtext.string.wide_char, (XIMP_MAXBUF + 1) * sizeof(wchar_t)); ! length = XIMP_MAXBUF; ! if (_Ximp_cttowcs(xic->core.im->core.lcd, text, nitems, ! cbtext.string.wide_char, ! &length, NULL) < 0) { length = 0; } cbtext.length = length; Xfree((XPointer) text); cbtext.encoding_is_wchar = True; } else { ! cbtext.string.multi_byte = Xmalloc(XIMP_MAXBUF + 1); ! bzero(cbtext.string.multi_byte, XIMP_MAXBUF + 1); ! length = XIMP_MAXBUF; ! if (_Ximp_cttombs(xic->core.im->core.lcd, text, nitems, ! cbtext.string.multi_byte, ! &length, NULL) < 0) { length = 0; } ! if (cbtext.length == 0) { ! if ((length = ! _Ximp_mbs_charlen(xic->core.im->core.lcd, cbtext.string.multi_byte, length)) < 0) { ! length = 0 ; ! if (cbtext.string.multi_byte) ! Xfree(cbtext.string.multi_byte); ! cbtext.string.multi_byte = NULL; } cbtext.length = length; } --- 574,613 ---- event->data.l[3], 0, 4096, True, AnyPropertyType, &type, &format, &nitems, &after, (unsigned char **) &text) == Success) { ! if (IS_USE_WCHAR(xic)) { ! if( (cbtext.string.wide_char = (wchar_t *) Xmalloc((XIMP_MAXBUF + 1) * sizeof(wchar_t))) == NULL ) { length = 0; } + else { + bzero(cbtext.string.wide_char, (XIMP_MAXBUF + 1) * sizeof(wchar_t)); + length = XIMP_MAXBUF; + if (_Ximp_cttowcs(xic->core.im->core.lcd, text, nitems, + cbtext.string.wide_char, + &length, NULL) < 0) { + length = 0; + } + } cbtext.length = length; Xfree((XPointer) text); cbtext.encoding_is_wchar = True; } else { ! if( (cbtext.string.multi_byte = Xmalloc(XIMP_MAXBUF + 1)) == NULL ) { length = 0; } ! else { ! bzero(cbtext.string.multi_byte, XIMP_MAXBUF + 1); ! length = XIMP_MAXBUF; ! if (_Ximp_cttombs(xic->core.im->core.lcd, text, nitems, ! cbtext.string.multi_byte, ! &length, NULL) < 0) { ! length = 0; ! } ! if (cbtext.length == 0) { ! if ((length = _Ximp_mbs_charlen(xic->core.im->core.lcd, cbtext.string.multi_byte, length)) < 0) { ! length = 0 ; ! } } cbtext.length = length; } *************** *** 626,638 **** cbtext.encoding_is_wchar = False; } } else { ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { ! cbtext.string.wide_char = (wchar_t *) Xmalloc(sizeof(wchar_t)); ! cbtext.string.wide_char[0] = 0; cbtext.length = 0; } else { ! cbtext.string.multi_byte = Xmalloc(1); ! cbtext.string.multi_byte[0] = 0; cbtext.length = 0; } } --- 615,625 ---- cbtext.encoding_is_wchar = False; } } else { ! if (IS_USE_WCHAR(xic)) { ! cbtext.string.wide_char = (wchar_t *) NULL; cbtext.length = 0; } else { ! cbtext.string.multi_byte = NULL; cbtext.length = 0; } } *************** *** 639,649 **** if (cb->callback) { (*cb->callback) (xic, cb->client_data, &CallData); } ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { ! Xfree((XPointer) (cbtext.string.wide_char)); ! } else { ! Xfree((XPointer) (cbtext.string.multi_byte)); } if (cbtext.feedback) Xfree((XPointer) cbtext.feedback); } else { /* XIMBitmapType */ --- 626,641 ---- if (cb->callback) { (*cb->callback) (xic, cb->client_data, &CallData); } ! if (IS_USE_WCHAR(xic) ) { ! if( cbtext.string.wide_char ) { ! Xfree((XPointer) (cbtext.string.wide_char)); ! } } + else { + if( cbtext.string.multi_byte ) { + Xfree((XPointer) (cbtext.string.multi_byte)); + } + } if (cbtext.feedback) Xfree((XPointer) cbtext.feedback); } else { /* XIMBitmapType */ *************** *** 659,709 **** Ximp_XIC xic; XClientMessageEvent *event; { ! register XIMCallback *cb; ! char *text; ! int length; XIMStatusDrawCallbackStruct CallData; ! XIMText cbtext; ! XEvent ev; ! XimpCMPredicateArgRec Arg; cb = &xic->core.status_attr.callbacks.draw; CallData.type = ToXIMStatusDataType(event->data.l[2]); if (CallData.type == XIMTextType) { CallData.data.text = &cbtext; ! ! Arg.type = ((Ximp_XIM)xic->core.im)->ximp_impart->improtocol_id; ! Arg.owner = ((Ximp_XIM)xic->core.im)->ximp_impart->fe_window; ! Arg.icid = xic->ximp_icpart->icid; ! if( !_XimpIfEvent( xic, &ev, _Ximp_DCMPredicate, (XPointer)&Arg ) ) ! return; ! if (cb->callback) { ! length = ev.xclient.data.b[4]; ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { ! cbtext.string.wide_char = (wchar_t *) Xmalloc((XIMP_MAXBUF + 1) * sizeof(wchar_t)); ! bzero(cbtext.string.wide_char,(XIMP_MAXBUF + 1) * sizeof(wchar_t)); cbtext.encoding_is_wchar = True; ! if (_Ximp_cttowcs(xic->core.im->core.lcd, ! &ev.xclient.data.b[5], ev.xclient.data.b[4], ! cbtext.string.wide_char, ! &length, NULL) < 0) { length = 0; } } else { - cbtext.string.multi_byte = Xmalloc(length + 1); - bzero(cbtext.string.multi_byte, length + 1); cbtext.encoding_is_wchar = False; ! if (_Ximp_cttombs(xic->core.im->core.lcd, ! &ev.xclient.data.b[5], ev.xclient.data.b[4], ! cbtext.string.multi_byte, ! &length, NULL) < 0) { length = 0; } ! if ((length = _Ximp_mbs_charlen(xic->core.im->core.lcd, ! cbtext.string.multi_byte, ! length)) < 0) { ! length = 0; } } cbtext.length = length; --- 651,705 ---- Ximp_XIC xic; XClientMessageEvent *event; { ! register XIMCallback *cb; ! unsigned char *ct = NULL; ! int length; XIMStatusDrawCallbackStruct CallData; ! XIMText cbtext; ! int ctlen = 0; /* for multiple ClientMessage */ cb = &xic->core.status_attr.callbacks.draw; CallData.type = ToXIMStatusDataType(event->data.l[2]); if (CallData.type == XIMTextType) { CallData.data.text = &cbtext; ! ! ctlen = _Ximp_CombineMultipleCM(xic, &ct); ! if (cb->callback) { ! length = ctlen * XIMP_MB_CUR_MAX(xic->core.im->core.lcd); ! if (IS_USE_WCHAR(xic)) { cbtext.encoding_is_wchar = True; ! if( (cbtext.string.wide_char = (wchar_t *) Xmalloc((XIMP_MAXBUF + 1) * sizeof(wchar_t))) == NULL ) { length = 0; } + else { + bzero(cbtext.string.wide_char,(XIMP_MAXBUF + 1) * sizeof(wchar_t)); + if (_Ximp_cttowcs(xic->core.im->core.lcd, + ct, ctlen, + cbtext.string.wide_char, + &length, NULL) < 0) { + length = 0; + } + } } else { cbtext.encoding_is_wchar = False; ! if( (cbtext.string.multi_byte = Xmalloc(length + 1)) == NULL ) { length = 0; } ! else { ! bzero(cbtext.string.multi_byte, length + 1); ! if (_Ximp_cttombs(xic->core.im->core.lcd, ! ct, ctlen, ! cbtext.string.multi_byte, ! &length, NULL) < 0) { ! length = 0; ! } ! Xfree((XPointer) ct); ! if ((length = _Ximp_mbs_charlen(xic->core.im->core.lcd, ! cbtext.string.multi_byte, ! length)) < 0) { ! length = 0; ! } } } cbtext.length = length; *************** *** 710,729 **** if (event->data.l[4] != -1) { int i; ! cbtext.feedback = (XIMFeedback *) Xmalloc(cbtext.length * sizeof(long)); ! for (i = 0; i < (int) cbtext.length; i++) { ! cbtext.feedback[i] = event->data.l[4]; ! } } else { cbtext.feedback = NULL; } (*cb->callback) (xic, cb->client_data, &CallData); ! if (((Ximp_XIM) xic->core.im)->ximp_impart->use_wchar) { ! Xfree((XPointer) (cbtext.string.wide_char)); ! } else { ! Xfree((XPointer) (cbtext.string.multi_byte)); } ! Xfree((XPointer) cbtext.feedback); } } else { /* XIMBitmapType */ if (cb->callback) { --- 706,730 ---- if (event->data.l[4] != -1) { int i; ! if( cbtext.feedback = (XIMFeedback *) Xmalloc(cbtext.length * sizeof(long)) ) ! for (i = 0; i < (int) cbtext.length; i++) ! cbtext.feedback[i] = event->data.l[4]; } else { cbtext.feedback = NULL; } (*cb->callback) (xic, cb->client_data, &CallData); ! if( IS_USE_WCHAR(xic) ) { ! if( cbtext.string.wide_char ) { ! Xfree((XPointer) (cbtext.string.wide_char)); ! } } ! else { ! if( cbtext.string.multi_byte ) { ! Xfree((XPointer) (cbtext.string.multi_byte)); ! } ! } ! if (cbtext.feedback) ! Xfree((XPointer) cbtext.feedback); } } else { /* XIMBitmapType */ if (cb->callback) { *** /tmp/d03366 Tue Mar 9 09:17:25 1993 --- mit/lib/X/Ximp/XimpConv.c Tue Mar 9 09:17:22 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpConv.c,v 1.6 92/04/14 13:28:45 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpConv.c,v 1.7 92/10/19 19:24:01 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 70,85 **** #define CHAR_LENGTH(xxxtocs) \ unsigned char buf[BUFSIZE]; \ - int char_length; \ int buf_len, scan_len; \ int ret = 0; \ \ ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); \ \ while (from_len > 0) { \ buf_len = BUFSIZE; \ ! scan_len = (*xxxtocs)(lcd, from_ptr, from_len, buf, &buf_len, \ ! NULL, &char_length); \ if (scan_len == -1) { \ ret = -1; \ goto error; \ --- 70,86 ---- #define CHAR_LENGTH(xxxtocs) \ unsigned char buf[BUFSIZE]; \ int buf_len, scan_len; \ int ret = 0; \ + LCMethods methods = LC_METHODS(lcd); \ + State state; \ \ ! state = (*methods->create_state)(lcd); \ ! (*methods->cnv_start)(state); \ \ while (from_len > 0) { \ buf_len = BUFSIZE; \ ! scan_len = (*xxxtocs)(state, from_ptr, from_len, buf, &buf_len); \ if (scan_len == -1) { \ ret = -1; \ goto error; \ *************** *** 87,105 **** if (scan_len == 0) \ break; \ \ ! ret += buf_len / char_length; \ from_ptr += scan_len; \ from_len -= scan_len; \ } \ \ error: \ ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); \ \ return ret; int ! _Ximp_str_charlen(lcd, strtocs, from, from_len) ! Ximp_XLCd lcd; int (*strtocs)(); unsigned char *from; int from_len; --- 88,107 ---- if (scan_len == 0) \ break; \ \ ! ret += buf_len / state->codeset->length; \ from_ptr += scan_len; \ from_len -= scan_len; \ } \ \ error: \ ! (*methods->cnv_end)(state); \ ! (*methods->destroy_state)(state); \ \ return ret; int ! _Xlc_str_charlen(lcd, strtocs, from, from_len) ! XLCd lcd; int (*strtocs)(); unsigned char *from; int from_len; *************** *** 110,201 **** int _Ximp_mbs_charlen(lcd, mbstr, mbstr_len) ! Ximp_XLCd lcd; unsigned char *mbstr; int mbstr_len; { ! return _Ximp_str_charlen(lcd, lcd->ximp_lcpart->methods->mbstocs, ! mbstr, mbstr_len); } #define STRING_CONV(xxxtocs, cstoxxx) \ unsigned char buf[BUFSIZE]; \ - int cs_num; \ int to_length, buf_len, scan_len, tmp_len; \ int ret = -1; \ \ if (to_len) { \ ! to_length = *to_len; \ *to_len = 0; \ } else \ ! to_length = MAXINT; \ ! if (unconv_num) \ ! *unconv_num = 0; \ \ ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); \ \ while (from_len > 0 && to_length > 0) { \ ! buf_len = BUFSIZE; \ ! scan_len = (*xxxtocs)(lcd, from_ptr, from_len, buf, &buf_len, \ ! &cs_num, NULL); \ ! if (scan_len == -1) \ ! goto error; \ ! if (scan_len == 0) \ break; \ \ ! from_ptr += scan_len; \ ! from_len -= scan_len; \ \ ! tmp_len = to_length; \ ! if ((*cstoxxx)(lcd, buf, buf_len, to_ptr, &tmp_len, cs_num) == -1) { \ ! if (unconv_num) { \ ! *unconv_num += scan_len; \ ! continue; \ ! } \ goto error; \ ! } \ \ if (to_ptr) \ ! to_ptr += tmp_len; \ if (to_len) \ *to_len += tmp_len; \ ! to_length -= tmp_len; \ } \ \ ret = from_ptr - from; \ \ error: \ ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); \ \ return ret; ! int ! _Ximp_strtostr(lcd, strtocs, from, from_len, cstostr, to, to_len, unconv_num) ! Ximp_XLCd lcd; int (*strtocs)(); unsigned char *from; int from_len; - int (*cstostr)(); - unsigned char *to; - int *to_len; - int *unconv_num; - { - unsigned char *from_ptr = from; - unsigned char *to_ptr = to; - STRING_CONV(strtocs, cstostr) - } - - int - _Ximp_strtowstr(lcd, strtocs, from, from_len, cstowstr, to, to_len, unconv_num) - Ximp_XLCd lcd; - int (*strtocs)(); - unsigned char *from; - int from_len; int (*cstowstr)(); wchar_t *to; int *to_len; - int *unconv_num; { unsigned char *from_ptr = from; wchar_t *to_ptr = to; --- 112,183 ---- int _Ximp_mbs_charlen(lcd, mbstr, mbstr_len) ! XLCd lcd; unsigned char *mbstr; int mbstr_len; { ! LCMethods methods = LC_METHODS(lcd); ! ! return _Xlc_str_charlen(lcd, methods->mbstocs, mbstr, mbstr_len); } #define STRING_CONV(xxxtocs, cstoxxx) \ unsigned char buf[BUFSIZE]; \ int to_length, buf_len, scan_len, tmp_len; \ int ret = -1; \ + LCMethods methods = LC_METHODS(lcd); \ + State state; \ \ if (to_len) { \ ! to_length = *to_len; \ *to_len = 0; \ } else \ ! to_length = MAXINT; \ \ ! state = (*methods->create_state)(lcd); \ ! (*methods->cnv_start)(state); \ \ while (from_len > 0 && to_length > 0) { \ ! buf_len = BUFSIZE; \ ! scan_len = (*xxxtocs)(state, from_ptr, from_len, buf, &buf_len); \ ! if (scan_len == -1) \ ! goto error; \ ! if (scan_len == 0) \ break; \ \ ! from_ptr += scan_len; \ ! from_len -= scan_len; \ \ ! tmp_len = to_length; \ ! if ((*cstoxxx)(state, buf, buf_len, to_ptr, &tmp_len) == -1) { \ goto error; \ ! } \ \ if (to_ptr) \ ! to_ptr += tmp_len; \ if (to_len) \ *to_len += tmp_len; \ ! to_length -= tmp_len; \ } \ \ ret = from_ptr - from; \ \ error: \ ! (*methods->cnv_end)(state); \ ! (*methods->destroy_state)(state); \ \ return ret; ! static int ! strtowstr(lcd, strtocs, from, from_len, cstowstr, to, to_len) ! XLCd lcd; int (*strtocs)(); unsigned char *from; int from_len; int (*cstowstr)(); wchar_t *to; int *to_len; { unsigned char *from_ptr = from; wchar_t *to_ptr = to; *************** *** 202,210 **** STRING_CONV(strtocs, cstowstr) } ! int ! _Ximp_wstrtostr(lcd, wstrtocs, from, from_len, cstostr, to, to_len, unconv_num) ! Ximp_XLCd lcd; int (*wstrtocs)(); wchar_t *from; int from_len; --- 184,192 ---- STRING_CONV(strtocs, cstowstr) } ! static int ! wstrtostr(lcd, wstrtocs, from, from_len, cstostr, to, to_len) ! XLCd lcd; int (*wstrtocs)(); wchar_t *from; int from_len; *************** *** 211,217 **** int (*cstostr)(); unsigned char *to; int *to_len; - int *unconv_num; { wchar_t *from_ptr = from; unsigned char *to_ptr = to; --- 193,198 ---- *************** *** 218,302 **** STRING_CONV(wstrtocs, cstostr) } - int - _Ximp_wstrtowstr(lcd, wstrtocs,from,from_len, cstowstr,to,to_len, unconv_num) - Ximp_XLCd lcd; - int (*wstrtocs)(); - wchar_t *from; - int from_len; - int (*cstowstr)(); - wchar_t *to; - int *to_len; - int *unconv_num; - { - wchar_t *from_ptr = from; - wchar_t *to_ptr = to; - STRING_CONV(wstrtocs, cstowstr) - } - int - _Ximp_mbstowcs(lcd, mbstr, mbstr_len, wcstr, wcstr_len, unconv_num) - Ximp_XLCd lcd; - unsigned char *mbstr; - int mbstr_len; - wchar_t *wcstr; - int *wcstr_len; - int *unconv_num; - { - if (lcd == NULL && (lcd = (Ximp_XLCd) _XlcCurrentLC()) == NULL) - return -1; - - return _Ximp_strtowstr(lcd, lcd->ximp_lcpart->methods->mbstocs, mbstr, - mbstr_len, lcd->ximp_lcpart->methods->cstowcs, - wcstr, wcstr_len, unconv_num); - } - - - int - _Ximp_wcstombs(lcd, wcstr, wcstr_len, mbstr, mbstr_len, unconv_num) - Ximp_XLCd lcd; - wchar_t *wcstr; - int wcstr_len; - unsigned char *mbstr; - int *mbstr_len; - int *unconv_num; - { - if (lcd == NULL && (lcd = (Ximp_XLCd) _XlcCurrentLC()) == NULL) - return -1; - - return _Ximp_wstrtostr(lcd, lcd->ximp_lcpart->methods->wcstocs, wcstr, - wcstr_len, lcd->ximp_lcpart->methods->cstombs, - mbstr, mbstr_len, unconv_num); - } - - int - _Ximp_strcpy(lcd, str1, str1_len, str2, str2_len, unconv_num) - Ximp_XLCd lcd; - register unsigned char *str1; - register int str1_len; - register unsigned char *str2; - int *str2_len; - int *unconv_num; - { - unsigned char *str1_tmp = str1; - - if (str2_len && str1_len > *str2_len) - str1_len = *str2_len; - - while (str1_len--) - *str2++ = *str1++; - - if (unconv_num) - *unconv_num = 0; - if (str2_len) - *str2_len = str1 - str1_tmp; - - return str1 - str1_tmp; - } - - - int _Xmblen(str, len) char *str; int len; --- 199,206 ---- *************** *** 310,322 **** char *str; int len; { ! Ximp_XLCd lcd = (Ximp_XLCd) _XlcCurrentLC(); wchar_t tmp_wc; if (lcd == NULL) return -1; if (str == NULL) ! return lcd->ximp_lcpart->state_dependent; if (len == 0) return 0; if (*str == '\0') { --- 214,228 ---- char *str; int len; { ! XimpLCd lcd = (XimpLCd) _XlcCurrentLC(); ! LCMethods methods = LC_METHODS(lcd); wchar_t tmp_wc; + int one = 1; if (lcd == NULL) return -1; if (str == NULL) ! return lcd->locale.state_dependent; if (len == 0) return 0; if (*str == '\0') { *************** *** 326,333 **** if (wstr == NULL) wstr = &tmp_wc; ! return _Ximp_strtowstr(lcd, lcd->ximp_lcpart->methods->mbstocs, str, len, ! lcd->ximp_lcpart->methods->cstowcs, wstr, 1, NULL); } int --- 232,239 ---- if (wstr == NULL) wstr = &tmp_wc; ! return strtowstr(lcd, methods->mbstocs, str, len, methods->cstowcs, ! wstr, &one); } int *************** *** 336,352 **** wchar_t wc; { int len; - Ximp_XLCd lcd = (Ximp_XLCd) _XlcCurrentLC(); - if (lcd == NULL) return -1; if (str == NULL) ! return lcd->ximp_lcpart->state_dependent; len = XIMP_MB_CUR_MAX(lcd); ! if (_Ximp_wstrtostr(lcd, lcd->ximp_lcpart->methods->wcstocs, &wc, 1, ! lcd->ximp_lcpart->methods->cstombs, str, &len, NULL) < 0) return -1; return len; --- 242,258 ---- wchar_t wc; { int len; + XimpLCd lcd = (XimpLCd) _XlcCurrentLC(); + LCMethods methods = LC_METHODS(lcd); if (lcd == NULL) return -1; if (str == NULL) ! return lcd->locale.state_dependent; len = XIMP_MB_CUR_MAX(lcd); ! if (wstrtostr(lcd, methods->wcstocs, &wc, 1, methods->cstombs, ! str, &len) < 0) return -1; return len; *************** *** 358,372 **** char *str; int len; { ! Ximp_XLCd lcd = (Ximp_XLCd) _XlcCurrentLC(); if (lcd == NULL) return -1; ! if (_Ximp_strtowstr(lcd, lcd->ximp_lcpart->methods->mbstocs, str, ! strlen(str), lcd->ximp_lcpart->methods->cstowcs, ! wstr, &len, NULL) < 0) return -1; return len; } --- 264,282 ---- char *str; int len; { ! XLCd lcd = _XlcCurrentLC(); ! LCMethods methods = LC_METHODS(lcd); ! int length = len; if (lcd == NULL) return -1; ! if (strtowstr(lcd, methods->mbstocs, str, strlen(str), methods->cstowcs, ! wstr, &len) < 0) return -1; + + if (len < length) + wstr[len] = (wchar_t) 0; return len; } *************** *** 377,391 **** wchar_t *wstr; int len; { ! Ximp_XLCd lcd = (Ximp_XLCd) _XlcCurrentLC(); if (lcd == NULL) return -1; ! if (_Ximp_wstrtostr(lcd, lcd->ximp_lcpart->methods->wcstocs, wstr, ! _Xwcslen(wstr), lcd->ximp_lcpart->methods->cstombs, ! str, &len, NULL) < 0) return -1; return len; } --- 287,304 ---- wchar_t *wstr; int len; { ! XLCd lcd = _XlcCurrentLC(); ! LCMethods methods = LC_METHODS(lcd); ! int length = len; if (lcd == NULL) return -1; ! if (wstrtostr(lcd, methods->wcstocs, wstr, _Xwcslen(wstr), methods->cstombs, str, &len) < 0) return -1; + + if (len < length) + str[len] = '\0'; return len; } *************** *** 431,439 **** --- 344,383 ---- return wstr_ptr - wstr; } + int + _Xwcscmp(wstr1, wstr2) + register wchar_t *wstr1, *wstr2; + { + for ( ; *wstr1 && *wstr2; wstr1++, wstr2++) + if (*wstr1 != *wstr2) + break; + return *wstr1 - *wstr2; + } + + int + _Xwcsncmp(wstr1, wstr2, len) + register wchar_t *wstr1, *wstr2; + register len; + { + for ( ; *wstr1 && *wstr2 && len > 0; wstr1++, wstr2++, len--) + if (*wstr1 != *wstr2) + break; + + if (len <= 0) + return 0; + + return *wstr1 - *wstr2; + } + + char * + #ifndef DYNAMICLIB XDefaultString() + #else + _XimpDefaultString(lcd) + XLCd lcd ; + #endif { return ""; } *** /tmp/d03388 Tue Mar 9 09:17:37 1993 --- mit/lib/X/Ximp/XimpCrFS.c Tue Mar 9 09:17:34 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpCrFS.c,v 1.6 92/04/14 13:28:48 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpCrFS.c,v 1.7 92/10/19 19:24:08 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 88,95 **** char *font_name; XFontStruct *font; FontSetDataRec *font_data_list[MAX_CODESET]; - unsigned min_char; - unsigned max_char; } FontInfoRec; /* method list */ --- 88,93 ---- *************** *** 107,149 **** _Ximp_wc_draw_image_string }; ! static Ximp_XFontSet initFontSet(lcd) ! Ximp_XLCd lcd; { ! Ximp_XFontSet ximp_fontset; XFontSetXimpRec *fspart; FontSetRec *fontset; ! int codeset_num = lcd->ximp_lcpart->codeset_num; ! ximp_fontset = (Ximp_XFontSet) Xmalloc(sizeof(Ximp_XFontSetRec)); if (ximp_fontset == NULL) return NULL; - fspart = (XFontSetXimpRec *) Xmalloc(sizeof(XFontSetXimpRec)); - if (fspart == NULL) - goto error; - fontset = (FontSetRec *) Xmalloc(sizeof(FontSetRec) * codeset_num); if (fontset == NULL) goto error; - - bzero(ximp_fontset, sizeof(Ximp_XFontSetRec)); - bzero(fspart, sizeof(XFontSetXimpRec)); bzero(fontset, sizeof(FontSetRec) * codeset_num); fspart->fontset_num = codeset_num; fspart->fontset = fontset; ximp_fontset->methods = &fontset_methods; ximp_fontset->core.lcd = (XLCd) lcd; - ximp_fontset->ximp_fspart = fspart; return ximp_fontset; error: - if (fspart) - Xfree(fspart); Xfree(ximp_fontset); return NULL; --- 105,139 ---- _Ximp_wc_draw_image_string }; ! static XimpFontSet initFontSet(lcd) ! XimpLCd lcd; { ! XimpFontSet ximp_fontset; XFontSetXimpRec *fspart; FontSetRec *fontset; ! int codeset_num = lcd->locale.codeset_num; ! ximp_fontset = (XimpFontSet) Xmalloc(sizeof(XimpFontSetRec)); if (ximp_fontset == NULL) return NULL; + bzero(ximp_fontset, sizeof(XimpFontSetRec)); fontset = (FontSetRec *) Xmalloc(sizeof(FontSetRec) * codeset_num); if (fontset == NULL) goto error; bzero(fontset, sizeof(FontSetRec) * codeset_num); + fspart = &ximp_fontset->ximp_fspart; fspart->fontset_num = codeset_num; fspart->fontset = fontset; ximp_fontset->methods = &fontset_methods; ximp_fontset->core.lcd = (XLCd) lcd; return ximp_fontset; error: Xfree(ximp_fontset); return NULL; *************** *** 151,179 **** static int getCharsetName(lcd, font_info) ! Ximp_XLCd lcd; FontInfoRec *font_info; { ! FontSetDataRec *data = lcd->ximp_lcpart->fontset_data; FontInfoRec *info_ptr; char *name; int count, data_num; ! int i; count = 0; ! data_num = lcd->ximp_lcpart->fontset_data_num; while (data_num--) { name = data->font_name; info_ptr = font_info; for (i = 0; i < count; i++, info_ptr++) if (!strcmp(name, info_ptr->charset_name)) { ! info_ptr->font_data_list[data->cset_number] = data; break; } if (i == count) { /* not found same font name */ info_ptr->charset_name = name; ! info_ptr->font_data_list[data->cset_number] = data; if (++count >= MAX_FONTSET) return count; } --- 141,171 ---- static int getCharsetName(lcd, font_info) ! XimpLCd lcd; FontInfoRec *font_info; { ! FontSetDataRec *data = lcd->locale.fontset_data; FontInfoRec *info_ptr; char *name; int count, data_num; ! int i, cs_num; count = 0; ! data_num = lcd->locale.fontset_data_num; while (data_num--) { name = data->font_name; info_ptr = font_info; for (i = 0; i < count; i++, info_ptr++) if (!strcmp(name, info_ptr->charset_name)) { ! cs_num = data->cs_num; ! info_ptr->font_data_list[cs_num] = data; break; } if (i == count) { /* not found same font name */ info_ptr->charset_name = name; ! cs_num = data->cs_num; ! info_ptr->font_data_list[cs_num] = data; if (++count >= MAX_FONTSET) return count; } *************** *** 247,259 **** checkCharSet(prop_fname, info_ptr->charset_name)) { fname = prop_fname; found: ! info_ptr->font_name = Xmalloc(strlen(fname) + 1); ! strcpy(info_ptr->font_name, fname); ! info_ptr->min_char = (fs_list->min_byte1 << 8) + ! fs_list->min_char_or_byte2; ! info_ptr->max_char = (fs_list->max_byte1 << 8) + ! fs_list->max_char_or_byte2; ! found_num++; break; } } --- 239,248 ---- checkCharSet(prop_fname, info_ptr->charset_name)) { fname = prop_fname; found: ! if( (info_ptr->font_name = Xmalloc(strlen(fname) + 1)) != NULL ) { ! strcpy(info_ptr->font_name, fname); ! found_num++; ! } break; } } *************** *** 268,347 **** } static Bool - check_ext_font(font_info, ext_font, ext_font_num) - FontInfoRec *font_info; - register ExtFontRec *ext_font; - int ext_font_num; - { - register unsigned min_char = font_info->min_char; - register unsigned max_char = font_info->max_char; - - while (ext_font_num--) { - if (min_char > ext_font->min_char && max_char < ext_font->max_char) - return False; - ext_font++; - } - - return True; - } - - static Bool setInternalPartData(lcd, dpy, xfont_set, font_info, font_info_num) ! Ximp_XLCd lcd; Display *dpy; ! Ximp_XFontSet xfont_set; FontInfoRec *font_info; int font_info_num; { ! FontSetRec *fontset = xfont_set->ximp_fspart->fontset; ! ExtFontRec ext_font[MAX_EXT_FONT], *ext_font_ptr; FontInfoRec *info_ptr; FontSetDataRec *data; char *font_name; ! int i,j, codeset_num, ext_font_num; ! codeset_num = lcd->ximp_lcpart->codeset_num; for (i = 0; i < codeset_num; i++, fontset++) { info_ptr = font_info; - ext_font_ptr = ext_font; - ext_font_num = 0; for (j = 0; j < font_info_num; j++, info_ptr++) { data = info_ptr->font_data_list[i]; if (data && (font_name = info_ptr->font_name)) { ! if (data->ext_flag) { ! if (ext_font_num < MAX_EXT_FONT && ! check_ext_font(info_ptr, ext_font, ext_font_num)) { ! ! if (info_ptr->font == NULL) ! info_ptr->font = XLoadQueryFont(dpy, font_name); ! if (ext_font_ptr->font = info_ptr->font) { ! ext_font_ptr->msb_mask = data->msb_mask; ! ext_font_ptr->min_char = info_ptr->min_char; ! ext_font_ptr->max_char = info_ptr->max_char; ! ext_font_ptr++; ! ext_font_num++; ! } ! } ! } else if (fontset->font == NULL) { if (info_ptr->font == NULL) info_ptr->font = XLoadQueryFont(dpy, font_name); fontset->font = info_ptr->font; ! fontset->msb_mask = data->msb_mask; } } } - - if (fontset->font && ext_font_num) { - ext_font_ptr = (ExtFontRec *) Xmalloc(ext_font_num * - sizeof(ExtFontRec)); - if (ext_font_ptr == NULL) - return False; - - fontset->ext_font_list = ext_font_ptr; - fontset->ext_font_num = ext_font_num; - for (j = 0; j < ext_font_num; j++) - *ext_font_ptr = ext_font[j]; - } } return True; --- 257,290 ---- } static Bool setInternalPartData(lcd, dpy, xfont_set, font_info, font_info_num) ! XimpLCd lcd; Display *dpy; ! XimpFontSet xfont_set; FontInfoRec *font_info; int font_info_num; { ! FontSetRec *fontset = xfont_set->ximp_fspart.fontset; FontInfoRec *info_ptr; FontSetDataRec *data; char *font_name; ! int i,j, codeset_num; ! codeset_num = lcd->locale.codeset_num; for (i = 0; i < codeset_num; i++, fontset++) { info_ptr = font_info; for (j = 0; j < font_info_num; j++, info_ptr++) { data = info_ptr->font_data_list[i]; if (data && (font_name = info_ptr->font_name)) { ! if (fontset->font == NULL) { if (info_ptr->font == NULL) info_ptr->font = XLoadQueryFont(dpy, font_name); fontset->font = info_ptr->font; ! fontset->codeset = lcd->locale.codeset_list[data->cs_num]; ! fontset->side = data->side; } } } } return True; *************** *** 349,355 **** static void setFontSetExtents(font_set) ! Ximp_XFontSet font_set; { XRectangle *ink = &font_set->core.font_set_extents.max_ink_extent; XRectangle *logical = &font_set->core.font_set_extents.max_logical_extent; --- 292,298 ---- static void setFontSetExtents(font_set) ! XimpFontSet font_set; { XRectangle *ink = &font_set->core.font_set_extents.max_ink_extent; XRectangle *logical = &font_set->core.font_set_extents.max_logical_extent; *************** *** 389,395 **** static Bool setCorePartData(font_set, font_info, font_info_num) ! Ximp_XFontSet font_set; FontInfoRec *font_info; int font_info_num; { --- 332,338 ---- static Bool setCorePartData(font_set, font_info, font_info_num) ! XimpFontSet font_set; FontInfoRec *font_info; int font_info_num; { *************** *** 453,466 **** static Bool setMissingList(lcd, xfont_set, font_info, font_info_num, missing_charset_list, missing_charset_count) ! Ximp_XLCd lcd; ! Ximp_XFontSet xfont_set; FontInfoRec *font_info; int font_info_num; char ***missing_charset_list; int *missing_charset_count; { ! FontSetRec *fontset = xfont_set->ximp_fspart->fontset; FontSetDataRec *data; char *name_list[MAX_CODESET], **charset_list, *charset_buf; int missing_cset_num[MAX_CODESET], missing_cset_count; --- 396,409 ---- static Bool setMissingList(lcd, xfont_set, font_info, font_info_num, missing_charset_list, missing_charset_count) ! XimpLCd lcd; ! XimpFontSet xfont_set; FontInfoRec *font_info; int font_info_num; char ***missing_charset_list; int *missing_charset_count; { ! FontSetRec *fontset = xfont_set->ximp_fspart.fontset; FontSetDataRec *data; char *name_list[MAX_CODESET], **charset_list, *charset_buf; int missing_cset_num[MAX_CODESET], missing_cset_count; *************** *** 467,473 **** int i, j, count, length, codeset_num; missing_cset_count = 0; ! codeset_num = lcd->ximp_lcpart->codeset_num; for (i = 0; i < codeset_num; i++) if (fontset[i].font == NULL) missing_cset_num[missing_cset_count++] = i; --- 410,416 ---- int i, j, count, length, codeset_num; missing_cset_count = 0; ! codeset_num = lcd->locale.codeset_num; for (i = 0; i < codeset_num; i++) if (fontset[i].font == NULL) missing_cset_num[missing_cset_count++] = i; *************** *** 480,486 **** if ((codeset_num = missing_cset_num[j]) < 0) continue; data = font_info->font_data_list[codeset_num]; ! if (data && data->ext_flag == False) { name_list[count++] = font_info->charset_name; length += strlen(font_info->charset_name) + 1; missing_cset_num[j] = -1; --- 423,429 ---- if ((codeset_num = missing_cset_num[j]) < 0) continue; data = font_info->font_data_list[codeset_num]; ! if (data) { name_list[count++] = font_info->charset_name; length += strlen(font_info->charset_name) + 1; missing_cset_num[j] = -1; *************** *** 511,518 **** } XFontSet ! _Ximp_Create_fontset(xlcd, dpy, base_name, name_list, count, ! missing_charset_list, missing_charset_count) XLCd xlcd; Display *dpy; char *base_name; --- 454,461 ---- } XFontSet ! _XDefaultCreateFontSet(xlcd, dpy, base_name, name_list, count, ! missing_charset_list, missing_charset_count) XLCd xlcd; Display *dpy; char *base_name; *************** *** 521,532 **** char ***missing_charset_list; int *missing_charset_count; { ! Ximp_XLCd lcd = (Ximp_XLCd) xlcd; ! Ximp_XFontSet font_set; FontInfoRec font_info[MAX_FONTSET]; char *name, **name_list_ptr, **fn_list, buf[BUFSIZE]; XFontStruct *fs_list; ! int i, fn_num, font_info_num, found_num = 0; *missing_charset_list = NULL; *missing_charset_count = 0; --- 464,476 ---- char ***missing_charset_list; int *missing_charset_count; { ! XimpLCd lcd = (XimpLCd) xlcd; ! XimpFontSet font_set; FontInfoRec font_info[MAX_FONTSET]; char *name, **name_list_ptr, **fn_list, buf[BUFSIZE]; XFontStruct *fs_list; ! int i, length, fn_num, font_info_num, found_num = 0; ! Bool is_found; *missing_charset_list = NULL; *missing_charset_count = 0; *************** *** 541,546 **** --- 485,525 ---- name_list_ptr = name_list; while (count--) { name = *name_list_ptr++; + length = strlen(name); + /* XXX */ + if (length > 1 && name[length - 1] == '*' && name[length - 2] == '-') { + (void) strcpy(buf, name); + is_found = False; + + for (i = 0; i < font_info_num; i++) { + if (font_info[i].font_name) + continue; + + if (length > 2 && name[length - 3] == '*') + (void) strcpy(buf + length - 1, font_info[i].charset_name); + else { + buf[length] = '-'; + (void) strcpy(buf + length + 1, font_info[i].charset_name); + } + fn_list = XListFonts(dpy, buf, 1, &fn_num); + if (fn_num == 0) + continue; + + font_info[i].font_name = Xmalloc(strlen(*fn_list) + 1); + if (font_info[i].font_name == NULL) + goto error; + (void) strcpy(font_info[i].font_name, *fn_list); + + XFreeFontNames(fn_list); + found_num++; + is_found = True; + } + if (found_num == font_info_num) + break; + if (is_found == True) + continue; + } + fn_list = XListFontsWithInfo(dpy, name, MAXFONTS, &fn_num, &fs_list); if (fn_num == 0) { char *p; *************** *** 613,628 **** Display *dpy; XFontSet xfont_set; { ! XFontSetXimpRec *fspart = ((Ximp_XFontSet) xfont_set)->ximp_fspart; FontSetRec *fontset = fspart->fontset; int num = fspart->fontset_num; ! while (num-- > 0) { ! if (fontset->ext_font_list) ! Xfree(fontset->ext_font_list); fontset++; - } Xfree(fspart->fontset); - Xfree(fspart); } --- 592,603 ---- Display *dpy; XFontSet xfont_set; { ! XFontSetXimpRec *fspart = &((XimpFontSet) xfont_set)->ximp_fspart; FontSetRec *fontset = fspart->fontset; int num = fspart->fontset_num; ! while (num-- > 0) fontset++; Xfree(fspart->fontset); } *** /tmp/d03410 Tue Mar 9 09:17:49 1993 --- mit/lib/X/Ximp/XimpIC.c Tue Mar 9 09:17:46 1993 *************** *** 1,8 **** ! /* $XConsortium: XimpIC.c,v 1.7 92/07/29 10:15:50 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED Copyright 1991, 1992 by Sony Corporation Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, --- 1,9 ---- ! /* $XConsortium: XimpIC.c,v 1.8 92/10/19 19:24:31 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED Copyright 1991, 1992 by Sony Corporation + Copyright 1991, 1992 by Sun Microsystems, Inc. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, *************** *** 9,24 **** provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of FUJITSU LIMITED ! and Sony Corporation not be used in advertising or publicity ! pertaining to distribution of the software without specific, ! written prior permission. ! FUJITSU LIMITED and Sony Corporation make no representations about ! the suitability of this software for any purpose. It is provided ! "as is" without express or implied warranty. ! FUJITSU LIMITED AND SONY CORPORATION DISCLAIM ALL WARRANTIES WITH ! REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER --- 10,25 ---- provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of FUJITSU LIMITED ! and Sony Corporation and Sun Microsystems, Inc. must not be used in ! advertising or publicity pertaining to distribution of the software ! without specific, written prior permission. ! FUJITSU LIMITED and Sony Corporation and Sun Microsystems, Inc. make no ! representations about the suitability of this software for any purpose. ! It is provided "as is" without express or implied warranty. ! FUJITSU LIMITED AND SONY CORPORATION AND SUN MICROSYTEMS, INC. DISCLAIM ! ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES ! OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER *************** *** 27,32 **** --- 28,34 ---- Author: Takashi Fujiwara FUJITSU LIMITED Makoto Wakamatsu Sony Corporation + Hideki Hiura Sun Microsystems, Inc. ******************************************************************/ *************** *** 49,374 **** extern char *_Ximp_SetICValueData(); extern void _Ximp_SetValue_Resource(); ! extern Bool _Ximp_SetOpenXIMP(); ! extern void _Ximp_SetFocusWindow(); extern void _Ximp_SetPreeditAtr(); extern void _Ximp_SetPreeditFont(); extern void _Ximp_SetStatusAtr(); extern void _Ximp_SetStatusFont(); extern Bool _Ximp_XimFilter_Keypress(); extern Bool _Ximp_XimFilter_Client(); - - static void _Ximp_AttributesSetL(); extern void _Ximp_IM_SendMessage(); static XICMethodsRec Ximp_ic_methods = { ! _Ximp_DestroyIC, /* destroy */ ! _Ximp_SetFocus, /* set_focus */ ! _Ximp_UnSetFocus, /* unset_focus */ ! _Ximp_SetICValues, /* set_values */ ! _Ximp_GetICValues, /* get_values */ ! _Ximp_MbReset, /* mb_reset */ ! _Ximp_WcReset, /* wc_reset */ ! _Ximp_MbLookupString, /* mb_lookup_string */ ! _Ximp_WcLookupString, /* wc_lookup_string */ ! }; XIC _Ximp_CreateIC(im, values) ! XIM im; ! XIMArg *values; { ! Ximp_XIC ic; ! long dummy; ! XICXimpRec *ximp_icpart; ! if((ic = (Ximp_XIC)Xmalloc(sizeof(Ximp_XICRec))) == (Ximp_XIC)NULL) { ! return((XIC)NULL); ! } ! if((ximp_icpart = (XICXimpRec *)Xmalloc(sizeof(XICXimpRec))) == (XICXimpRec *)NULL) { ! Xfree(ic); ! return((XIC)NULL); ! } ! bzero((char *)ic, sizeof(Ximp_XICRec)); ! bzero((char *)ximp_icpart, sizeof(XICXimpRec)); ! ic->methods = &Ximp_ic_methods; ! ic->core.im = im; ! /* Filter Event : for Ximp Protocol */ ! ic->core.filter_events = KeyPressMask | KeyReleaseMask | StructureNotifyMask; ! ic->ximp_icpart = ximp_icpart; ! if(_Ximp_SetICValueData(ic, values, XIMP_CREATE_IC, &dummy)) ! goto Set_Error; ! ! /* The Value must be set */ ! if(!(ximp_icpart->value_mask & XIMP_INPUT_STYLE)) /* Input Style */ ! goto Set_Error; ! if(ic->core.input_style & XIMPreeditPosition) ! if(!(ximp_icpart->proto_mask & XIMP_PRE_SPOTL_MASK)) /* SpotLocation */ ! goto Set_Error; ! if( (ic->core.input_style & XIMPreeditPosition) ! || (ic->core.input_style & XIMPreeditArea) ) ! if(!(ximp_icpart->proto_mask & XIMP_PRE_FONT_MASK)) /* FontSet */ ! goto Set_Error; ! if(ic->core.input_style & XIMStatusArea) ! if(!(ximp_icpart->proto_mask & XIMP_STS_FONT_MASK)) /* FontSet */ ! goto Set_Error; ! if(ic->core.input_style & XIMPreeditCallbacks) ! if(!(ximp_icpart->value_mask & XIMP_PRE_CALLBAK)) /* Preedit Callback */ ! goto Set_Error; ! if(ic->core.input_style & XIMStatusCallbacks) ! if(!(ximp_icpart->value_mask & XIMP_STS_CALLBAK)) /* Status Callback */ ! goto Set_Error; ! ! _Ximp_SetValue_Resource(ic, &dummy); ! if(((Ximp_XIM)im)->ximp_impart->inputserver || ! ((Ximp_XIM)im)->ximp_impart->connectserver) { ! if(_Ximp_SetOpenXIMP(ic, XIMP_CREATE_IC) == False) ! goto Set_Error; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_FOCUS_WIN_MASK) { ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyPress, KeyPress, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! ic->ximp_icpart->filter_mode |= 0x1; ! _XRegisterFilterByType(ic->core.im->core.display, ! ic->core.focus_window, ! ClientMessage, ClientMessage, ! _Ximp_XimFilter_Client, NULL); ! ic->ximp_icpart->filter_mode |= 0x2; ! } } ! return((XIC)ic); ! Set_Error : ! Xfree(ic); ! Xfree(ximp_icpart); ! return((XIC)NULL); } static void _Ximp_DestroyIC(ic) ! Ximp_XIC ic; { ! if(ic->ximp_icpart->filter_mode & 0x1) { ! _XUnregisterFilter (ic->core.im->core.display, ! ic->core.focus_window, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! } ! if(ic->ximp_icpart->filter_mode & 0x2) { ! _XUnregisterFilter(ic->core.im->core.display, ! ic->ximp_icpart->back_focus_win, ! _Ximp_XimFilter_Client, (XPointer)NULL); ! } ! _Ximp_IM_SendMessage(ic, XIMP_DESTROY, NULL, NULL, NULL); ! if( ic->ximp_icpart->preedit_font ) ! Xfree( ic->ximp_icpart->preedit_font ); ! if( ic->ximp_icpart->status_font ) ! Xfree( ic->ximp_icpart->status_font ); ! Xfree(ic->ximp_icpart); ! return; } static void _Ximp_SetFocus(ic) ! Ximp_XIC ic; { ! _Ximp_IM_SendMessage(ic, XIMP_SETFOCUS, NULL, NULL, NULL); ! if(!(ic->ximp_icpart->filter_mode & 0x1)) { ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyPress, KeyPress, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! ic->ximp_icpart->filter_mode |= 0x1; ! } ! return; } static void _Ximp_UnSetFocus(ic) ! Ximp_XIC ic; { ! _Ximp_IM_SendMessage(ic, XIMP_UNSETFOCUS, NULL, NULL, NULL); ! if(ic->ximp_icpart->filter_mode & 0x1) { ! _XUnregisterFilter (ic->core.im->core.display, ! ic->core.focus_window, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! ic->ximp_icpart->filter_mode &= ~(0x1); ! } ! return; } void ! _Ximp_SetFocusWindow(ic) ! Ximp_XIC ic; { ! XChangeProperty(ic->core.im->core.display, ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->focus_win_id, ! XA_WINDOW, 32, PropModeReplace, ! (unsigned char *)&ic->core.focus_window, 1); ! if(ic->ximp_icpart->filter_mode & 0x2) { ! _XUnregisterFilter(ic->core.im->core.display, ! ic->ximp_icpart->back_focus_win, ! _Ximp_XimFilter_Client, (XPointer)NULL); ! } _XRegisterFilterByType(ic->core.im->core.display, ! ic->core.focus_window, ! ClientMessage, ClientMessage, ! _Ximp_XimFilter_Client, NULL); ! ic->ximp_icpart->filter_mode |= 0x2; ! if(ic->ximp_icpart->filter_mode & 0x1) { ! _XUnregisterFilter (ic->core.im->core.display, ! ic->ximp_icpart->back_focus_win, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! } ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyPress, KeyPress, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! ic->ximp_icpart->filter_mode |= 0x1; ! return; } void _Ximp_SetPreeditAtr(ic) ! Ximp_XIC ic; { ! Ximp_PreeditPropRec *preedit_atr; ! unsigned char prop_data[XIMP_PREEDIT_MAX_CHAR]; ! preedit_atr = &(ic->ximp_icpart->preedit_attr); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Area.x, 0); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Area.y, 4); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Area.width, 8); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Area.height, 12); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Foreground, 16); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Background, 20); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Colormap, 24); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Bg_Pixmap, 28); ! _Ximp_AttributesSetL(prop_data, preedit_atr->LineSpacing, 32); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Cursor, 36); ! _Ximp_AttributesSetL(prop_data, preedit_atr->AreaNeeded.width, 40); _Ximp_AttributesSetL(prop_data, preedit_atr->AreaNeeded.height, 44); ! _Ximp_AttributesSetL(prop_data, preedit_atr->SpotLocation.x, 48); ! _Ximp_AttributesSetL(prop_data, preedit_atr->SpotLocation.y, 52); ! XChangeProperty(ic->core.im->core.display, ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id, ! ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id, ! 32, PropModeReplace, prop_data, XIMP_PREEDIT_MAX_LONG); ! return; } void _Ximp_SetPreeditFont(ic) ! Ximp_XIC ic; { ! if (ic->core.preedit_attr.fontset != NULL) { ! XChangeProperty(ic->core.im->core.display, ic->core.client_window, ((Ximp_XIM)ic->core.im)->ximp_impart->preeditfont_id, XA_STRING, 8, PropModeReplace, (unsigned char *)(ic->ximp_icpart->preedit_font), strlen(ic->ximp_icpart->preedit_font)); ! } ! return; } void _Ximp_SetStatusAtr(ic) ! Ximp_XIC ic; { ! Ximp_StatusPropRec *status_atr; ! unsigned char prop_data[XIMP_STATUS_MAX_CHAR]; ! status_atr = &(ic->ximp_icpart->status_attr); ! _Ximp_AttributesSetL(prop_data, status_atr->Area.x, 0); ! _Ximp_AttributesSetL(prop_data, status_atr->Area.y, 4); ! _Ximp_AttributesSetL(prop_data, status_atr->Area.width, 8); ! _Ximp_AttributesSetL(prop_data, status_atr->Area.height, 12); ! _Ximp_AttributesSetL(prop_data, status_atr->Foreground, 16); ! _Ximp_AttributesSetL(prop_data, status_atr->Background, 20); ! _Ximp_AttributesSetL(prop_data, status_atr->Colormap, 24); ! _Ximp_AttributesSetL(prop_data, status_atr->Bg_Pixmap, 28); ! _Ximp_AttributesSetL(prop_data, status_atr->LineSpacing, 32); ! _Ximp_AttributesSetL(prop_data, status_atr->Cursor, 36); ! _Ximp_AttributesSetL(prop_data, status_atr->AreaNeeded.width, 40); _Ximp_AttributesSetL(prop_data, status_atr->AreaNeeded.height, 44); ! _Ximp_AttributesSetL(prop_data, status_atr->window, 48); ! XChangeProperty(ic->core.im->core.display, ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id, ! ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id, ! 32, PropModeReplace, prop_data, XIMP_STATUS_MAX_LONG); ! return; } void _Ximp_SetStatusFont(ic) ! Ximp_XIC ic; { ! if (ic->core.status_attr.fontset != NULL) { ! XChangeProperty(ic->core.im->core.display, ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->statusfont_id, ! XA_STRING, 8, PropModeReplace, ! (unsigned char *)(ic->ximp_icpart->status_font), ! strlen(ic->ximp_icpart->status_font)); ! } ! return; } - static void - _Ximp_AttributesSetL(data, setdata, cnt) - char *data; - long setdata; - int cnt; - { - long *ptr; - - ptr = (long *)&data[cnt]; - *ptr = setdata; - return; - } - void _Ximp_IM_SendMessage(ic, request, data1, data2, data3) ! Ximp_XIC ic; ! unsigned long request; ! unsigned long data1, data2, data3; { ! XEvent Message; ! ! if((request != XIMP_CREATE) && !(ic->ximp_icpart->icid)) ! return; ! /* ClientMessage Send */ ! Message.xclient.type = ClientMessage; ! Message.xclient.display = ic->core.im->core.display; ! Message.xclient.window = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; ! Message.xclient.message_type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; ! Message.xclient.format = 32; ! Message.xclient.data.l[0] = request; ! if(request == XIMP_CREATE) ! Message.xclient.data.l[1] = (long)ic->core.client_window; ! else ! Message.xclient.data.l[1] = ic->ximp_icpart->icid; ! Message.xclient.data.l[2] = data1; ! Message.xclient.data.l[3] = data2; ! Message.xclient.data.l[4] = data3; ! XSendEvent(ic->core.im->core.display, ! ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window, ! False, NoEventMask, &Message); ! XFlush(ic->core.im->core.display); ! return; } --- 51,439 ---- extern char *_Ximp_SetICValueData(); extern void _Ximp_SetValue_Resource(); ! extern Bool _Ximp_ConnectIC(); ! extern void _Ximp_SetFocusWindowProp(); ! extern void _Ximp_SetFocusWindowFilter(); extern void _Ximp_SetPreeditAtr(); extern void _Ximp_SetPreeditFont(); extern void _Ximp_SetStatusAtr(); extern void _Ximp_SetStatusFont(); extern Bool _Ximp_XimFilter_Keypress(); + extern Bool _Ximp_XimFilter_Keyrelease(); extern Bool _Ximp_XimFilter_Client(); extern void _Ximp_IM_SendMessage(); static XICMethodsRec Ximp_ic_methods = { ! _Ximp_DestroyIC, /* destroy */ ! _Ximp_SetFocus, /* set_focus */ ! _Ximp_UnSetFocus, /* unset_focus */ ! _Ximp_SetICValues, /* set_values */ ! _Ximp_GetICValues, /* get_values */ ! _Ximp_MbReset, /* mb_reset */ ! _Ximp_WcReset, /* wc_reset */ ! _Ximp_MbLookupString, /* mb_lookup_string */ ! _Ximp_WcLookupString, /* wc_lookup_string */ ! }; XIC _Ximp_CreateIC(im, values) ! XIM im; ! XIMArg *values; { ! Ximp_XIC ic; ! XimpChangeMaskRec dummy; ! XICXimpRec *ximp_icpart; ! if((ic = (Ximp_XIC)Xmalloc(sizeof(Ximp_XICRec))) == (Ximp_XIC)NULL) ! return((XIC)NULL); ! if((ximp_icpart = (XICXimpRec *)Xmalloc(sizeof(XICXimpRec))) ! == (XICXimpRec *)NULL) { ! Xfree(ic); ! return((XIC)NULL); ! } ! bzero((char *)ic, sizeof(Ximp_XICRec)); ! bzero((char *)ximp_icpart, sizeof(XICXimpRec)); ! ic->methods = &Ximp_ic_methods; ! ic->core.im = im; ! /* Filter Event : for Ximp Protocol */ ! ic->core.filter_events ! = KeyPressMask | KeyReleaseMask | StructureNotifyMask; ! ximp_icpart->svr_mode = ((Ximp_XIM)im)->ximp_impart->def_svr_mode; ! ic->ximp_icpart = ximp_icpart; ! ! if(_Ximp_SetICValueData(ic, values, XIMP_CREATE_IC, &dummy)) ! goto Set_Error; ! ! /* The Value must be set */ ! if(!(ximp_icpart->value_mask & XIMP_INPUT_STYLE)) /* Input Style */ ! goto Set_Error; ! ! if(ic->core.input_style & XIMPreeditCallbacks) ! if(!(ximp_icpart->value_mask & XIMP_PRE_CALLBAK)) /* Preedit Callback */ ! goto Set_Error; ! if(ic->core.input_style & XIMStatusCallbacks) ! if(!(ximp_icpart->value_mask & XIMP_STS_CALLBAK)) /* Status Callback */ ! goto Set_Error; ! ! if(IS_UNCONNECTABLE(im)) { ! if(_Ximp_ConnectIC(ic, XIMP_CREATE_IC) == False) ! goto Set_Error; ! } else { ! if(IS_SERVER_CONNECTED(im)) { ! if(_Ximp_ConnectIC(ic, XIMP_CREATE_IC)) ! return((XIC)ic); } ! if( XIMP_CHK_FOCUSWINMASK(ic) ) { ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyPress, KeyPress, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyRelease, KeyRelease, ! _Ximp_XimFilter_Keyrelease, ! (XPointer)ic); ! ic->ximp_icpart->filter_mode |= 0x1; ! } ! } ! return((XIC)ic); ! Set_Error : ! Xfree(ic); ! Xfree(ximp_icpart); ! return((XIC)NULL); } static void _Ximp_DestroyIC(ic) ! Ximp_XIC ic; { ! if(ic->ximp_icpart->filter_mode & 0x1) { ! _XUnregisterFilter (ic->core.im->core.display, ! ic->core.focus_window, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! _XUnregisterFilter (ic->core.im->core.display, ! ic->core.focus_window, ! _Ximp_XimFilter_Keyrelease, ! (XPointer)ic); ! } ! if(ic->ximp_icpart->filter_mode & 0x2) { ! _XUnregisterFilter(ic->core.im->core.display, ! ic->ximp_icpart->back_focus_win, ! _Ximp_XimFilter_Client, (XPointer)ic); ! } ! if(ic->ximp_icpart->filter_mode & 0x4) { /* XXXXX */ ! _XUnregisterFilter(ic->core.im->core.display, ! ic->core.client_window, ! _Ximp_XimFilter_Client, (XPointer)ic); ! } ! if(IS_IC_CONNECTED(ic)) ! _Ximp_IM_SendMessage(ic, XIMP_DESTROY(ic), NULL, NULL, NULL); ! Xfree(ic->ximp_icpart); ! return; } static void _Ximp_SetFocus(ic) ! Ximp_XIC ic; { ! if(IS_IC_CONNECTED(ic)) ! _Ximp_IM_SendMessage(ic, XIMP_SETFOCUS(ic), NULL, NULL, NULL); ! if(!(ic->ximp_icpart->filter_mode & 0x1)) { ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyPress, KeyPress, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyRelease, KeyRelease, ! _Ximp_XimFilter_Keyrelease, ! (XPointer)ic); ! ic->ximp_icpart->filter_mode |= 0x1; ! } ! return; } static void _Ximp_UnSetFocus(ic) ! Ximp_XIC ic; { ! if(IS_IC_CONNECTED(ic)) ! _Ximp_IM_SendMessage(ic, XIMP_UNSETFOCUS(ic), NULL, NULL, NULL); ! if(ic->ximp_icpart->filter_mode & 0x1) { ! _XUnregisterFilter (ic->core.im->core.display, ! ic->core.focus_window, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! _XUnregisterFilter (ic->core.im->core.display, ! ic->core.focus_window, ! _Ximp_XimFilter_Keyrelease, ! (XPointer)ic); ! ic->ximp_icpart->filter_mode &= ~(0x1); ! } ! return; } void ! _Ximp_SetFocusWindowFilter(ic) ! Ximp_XIC ic; { ! if(ic->ximp_icpart->filter_mode & 0x1) { ! _XUnregisterFilter (ic->core.im->core.display, ! ic->ximp_icpart->back_focus_win, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! _XUnregisterFilter (ic->core.im->core.display, ! ic->ximp_icpart->back_focus_win, ! _Ximp_XimFilter_Keyrelease, ! (XPointer)ic); ! } ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyPress, KeyPress, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyRelease, KeyRelease, ! _Ximp_XimFilter_Keyrelease, ! (XPointer)ic); ! ic->ximp_icpart->filter_mode |= 0x1; ! if(ic->ximp_icpart->filter_mode & 0x2) { ! _XUnregisterFilter(ic->core.im->core.display, ! ic->ximp_icpart->back_focus_win, ! _Ximp_XimFilter_Client, (XPointer)ic); ! } ! _XRegisterFilterByType(ic->core.im->core.display, ! ic->core.focus_window, ! ClientMessage, ClientMessage, ! _Ximp_XimFilter_Client, (XPointer)ic); ! ic->ximp_icpart->filter_mode |= 0x2; ! ! if(!(ic->ximp_icpart->filter_mode & 0x4)) { /* XXXXX */ _XRegisterFilterByType(ic->core.im->core.display, ! ic->core.client_window, ! ClientMessage, ClientMessage, ! _Ximp_XimFilter_Client, (XPointer)ic); ! ic->ximp_icpart->filter_mode |= 0x4; ! } ! return; ! } ! static void ! _Ximp_AttributesSetL(data, setdata, cnt) ! char *data; ! long setdata; ! int cnt; ! { ! long *ptr; ! ! ptr = (long *)&data[cnt]; ! *ptr = setdata; ! return; } void + _Ximp_SetFocusWindowProp(ic) + Ximp_XIC ic; + { + XChangeProperty(ic->core.im->core.display, ic->core.client_window, + ((Ximp_XIM)ic->core.im)->ximp_impart->focus_win_id, + XA_WINDOW, 32, PropModeReplace, + (unsigned char *)&ic->core.focus_window, 1); + return; + } + + void _Ximp_SetPreeditAtr(ic) ! Ximp_XIC ic; { ! Ximp_PreeditPropRec4 *preedit_atr; ! unsigned char prop_data[XIMP_PREEDIT_MAX_CHAR4]; ! preedit_atr = &(ic->ximp_icpart->preedit_attr); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Area.x, 0); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Area.y, 4); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Area.width, 8); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Area.height, 12); ! if(ISXimp4(ic)) { ! _Ximp_AttributesSetL(prop_data, preedit_atr->AreaNeeded.width, 16); ! _Ximp_AttributesSetL(prop_data, preedit_atr->AreaNeeded.height, 20); ! _Ximp_AttributesSetL(prop_data, preedit_atr->SpotLocation.x, 24); ! _Ximp_AttributesSetL(prop_data, preedit_atr->SpotLocation.y, 28); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Colormap, 32); ! _Ximp_AttributesSetL(prop_data, preedit_atr->StdColormap, 36); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Foreground, 40); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Background, 44); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Bg_Pixmap, 48); ! _Ximp_AttributesSetL(prop_data, preedit_atr->LineSpacing, 52); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Cursor, 56); ! } else { ! _Ximp_AttributesSetL(prop_data, preedit_atr->Foreground, 16); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Background, 20); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Colormap, 24); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Bg_Pixmap, 28); ! _Ximp_AttributesSetL(prop_data, preedit_atr->LineSpacing, 32); ! _Ximp_AttributesSetL(prop_data, preedit_atr->Cursor, 36); ! _Ximp_AttributesSetL(prop_data, preedit_atr->AreaNeeded.width, 40); _Ximp_AttributesSetL(prop_data, preedit_atr->AreaNeeded.height, 44); ! _Ximp_AttributesSetL(prop_data, preedit_atr->SpotLocation.x, 48); ! _Ximp_AttributesSetL(prop_data, preedit_atr->SpotLocation.y, 52); ! } ! XChangeProperty(ic->core.im->core.display, ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id, ! ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id, ! 32, PropModeReplace, prop_data, XIMP_PREEDIT_MAX_LONG(ic)); ! return; } void _Ximp_SetPreeditFont(ic) ! Ximp_XIC ic; { ! if (ic->core.preedit_attr.fontset != NULL) { ! XChangeProperty(ic->core.im->core.display, ic->core.client_window, ((Ximp_XIM)ic->core.im)->ximp_impart->preeditfont_id, XA_STRING, 8, PropModeReplace, (unsigned char *)(ic->ximp_icpart->preedit_font), strlen(ic->ximp_icpart->preedit_font)); ! } } void _Ximp_SetStatusAtr(ic) ! Ximp_XIC ic; { ! Ximp_StatusPropRec4 *status_atr; ! unsigned char prop_data[XIMP_STATUS_MAX_CHAR4]; ! status_atr = &(ic->ximp_icpart->status_attr); ! _Ximp_AttributesSetL(prop_data, status_atr->Area.x, 0); ! _Ximp_AttributesSetL(prop_data, status_atr->Area.y, 4); ! _Ximp_AttributesSetL(prop_data, status_atr->Area.width, 8); ! _Ximp_AttributesSetL(prop_data, status_atr->Area.height, 12); ! if(ISXimp4(ic)) { ! _Ximp_AttributesSetL(prop_data, status_atr->AreaNeeded.width, 16); ! _Ximp_AttributesSetL(prop_data, status_atr->AreaNeeded.height, 20); ! _Ximp_AttributesSetL(prop_data, status_atr->Colormap, 24); ! _Ximp_AttributesSetL(prop_data, status_atr->StdColormap, 28); ! _Ximp_AttributesSetL(prop_data, status_atr->Foreground, 32); ! _Ximp_AttributesSetL(prop_data, status_atr->Background, 36); ! _Ximp_AttributesSetL(prop_data, status_atr->Bg_Pixmap, 40); ! _Ximp_AttributesSetL(prop_data, status_atr->LineSpacing, 44); ! _Ximp_AttributesSetL(prop_data, status_atr->Cursor, 48); ! _Ximp_AttributesSetL(prop_data, status_atr->window, 52); ! } else { ! _Ximp_AttributesSetL(prop_data, status_atr->Foreground, 16); ! _Ximp_AttributesSetL(prop_data, status_atr->Background, 20); ! _Ximp_AttributesSetL(prop_data, status_atr->Colormap, 24); ! _Ximp_AttributesSetL(prop_data, status_atr->Bg_Pixmap, 28); ! _Ximp_AttributesSetL(prop_data, status_atr->LineSpacing, 32); ! _Ximp_AttributesSetL(prop_data, status_atr->Cursor, 36); ! _Ximp_AttributesSetL(prop_data, status_atr->AreaNeeded.width, 40); _Ximp_AttributesSetL(prop_data, status_atr->AreaNeeded.height, 44); ! _Ximp_AttributesSetL(prop_data, status_atr->window, 48); ! } ! XChangeProperty(ic->core.im->core.display, ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id, ! ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id, ! 32, PropModeReplace, prop_data, XIMP_STATUS_MAX_LONG(ic)); ! return; } void _Ximp_SetStatusFont(ic) ! Ximp_XIC ic; { ! if (ic->core.status_attr.fontset != NULL) { ! XChangeProperty(ic->core.im->core.display, ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->statusfont_id, ! XA_STRING, 8, PropModeReplace, ! (unsigned char *)(ic->ximp_icpart->status_font), ! strlen(ic->ximp_icpart->status_font)); ! } } void _Ximp_IM_SendMessage(ic, request, data1, data2, data3) ! Ximp_XIC ic; ! unsigned long request; ! unsigned long data1, data2, data3; { ! XEvent Message; ! if(!(IS_IC_CONNECTED(ic)) && (request != XIMP_CREATE(ic))) ! return; ! ! /* ClientMessage Send */ ! Message.xclient.type = ClientMessage; ! Message.xclient.display = ic->core.im->core.display; ! Message.xclient.window = ((Ximp_XIM)ic->core.im)-> ! ximp_impart->fe_window; ! Message.xclient.message_type = ((Ximp_XIM)ic->core.im)-> ! ximp_impart->improtocol_id; ! Message.xclient.format = 32; ! Message.xclient.data.l[0] = request; ! if(request == XIMP_CREATE(ic)) ! Message.xclient.data.l[1] = (long)ic->core.client_window; ! else ! Message.xclient.data.l[1] = ic->ximp_icpart->icid; ! Message.xclient.data.l[2] = data1; ! Message.xclient.data.l[3] = data2; ! Message.xclient.data.l[4] = data3; ! XSendEvent(ic->core.im->core.display, ! ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window, ! False, NoEventMask, &Message); ! XFlush(ic->core.im->core.display); ! return; } *** /tmp/d03432 Tue Mar 9 09:18:02 1993 --- mit/lib/X/Ximp/XimpIM.c Tue Mar 9 09:17:59 1993 *************** *** 1,7 **** ! /* $XConsortium: XimpIM.c,v 1.8 92/07/29 10:16:10 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED Copyright 1991, 1992 by Sony Corporation Permission to use, copy, modify, distribute, and sell this software --- 1,8 ---- ! /* $XConsortium: XimpIM.c,v 1.9 92/10/19 19:24:44 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED + Copyright 1991, 1992 by Sun Microsystems, Inc. Copyright 1991, 1992 by Sony Corporation Permission to use, copy, modify, distribute, and sell this software *************** *** 8,31 **** and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear ! in supporting documentation, and that the name of FUJITSU LIMITED ! and Sony Corporation not be used in advertising or publicity ! pertaining to distribution of the software without specific, written prior permission. ! FUJITSU LIMITED and Sony Corporation make no representations about ! the suitability of this software for any purpose. It is provided ! "as is" without express or implied warranty. ! FUJITSU LIMITED AND SONY CORPORATION DISCLAIM ALL WARRANTIES WITH ! REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND ! SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL ! DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA ! OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ! TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ! PERFORMANCE OF THIS SOFTWARE. Author: Takashi Fujiwara FUJITSU LIMITED Makoto Wakamatsu Sony Corporation ******************************************************************/ --- 9,34 ---- and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear ! in supporting documentation, and that the name of FUJITSU LIMITED, ! Sun Microsystems, Inc. and Sony Corporation not be used in advertising ! or publicity pertaining to distribution of the software without specific, written prior permission. ! FUJITSU LIMITED, Sun Microsystems, Inc. and Sony Corporation make no ! representations about the suitability of this software for any purpose. ! It is provided "as is" without express or implied warranty. ! FUJITSU LIMITED, SUN MICROSYSTEMS, INC. AND SONY CORPORATION DISCLAIM ! ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED ! WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU ! LIMITED, SUN MICROSYSTEMS, INC. AND SONY CORPORATION BE LIABLE FOR ANY ! SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ! RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF ! CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN ! CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Author: Takashi Fujiwara FUJITSU LIMITED + Hiromu Inukai Sun Microsystems, Inc. + Hideki Hiura Sun Microsystems, Inc. Makoto Wakamatsu Sony Corporation ******************************************************************/ *************** *** 36,541 **** #include "Xlcint.h" #include "Ximplc.h" static Status _Ximp_CloseIM(); static char *_Ximp_GetIMValues(); extern XIC _Ximp_CreateIC(); ! extern Bool _Ximp_OpenIM_Resource(); extern Ximp_XIC _Ximp_LookupXIC(); extern int _Ximp_SetupFree(); ! extern Bool _Ximp_Setup(); extern void _Ximp_SetupExtension(); extern Bool _Ximp_GetIMExtension(); - static Bool _Ximp_GetStyle(); - extern Bool _Ximp_XimFilter_Destroy(); Ximp_XIM *Ximp_Xim_List = (Ximp_XIM *)NULL; int Ximp_Xim_count = 0; ! static Atom Protocol_ID; static XIMMethodsRec Ximp_im_methods = { ! _Ximp_CloseIM, /* close */ ! _Ximp_GetIMValues, /* get_values */ ! _Ximp_CreateIC, /* create_ic */ ! }; ! char *_Ximp_Strstr( src, dest ) register char *src, *dest; { register len; ! ! if( src == NULL || dest == NULL ) return( NULL ); len = strlen(dest); ! while( src = index( src, *dest ) ) { ! if( strncmp( src, dest, len ) == 0 ) ! return( src ); src++; } ! return( NULL ); } ! XIM ! _Ximp_OpenIM(lcd, dpy, rdb, res_name, res_class) ! XLCd lcd; ! Display *dpy; ! XrmDatabase rdb; ! char *res_name, *res_class; { ! Ximp_XIM im; ! XIMXimpRec *ximp_impart; ! Bool ret; ! if((im = (Ximp_XIM)Xmalloc(sizeof(Ximp_XIMRec))) == (Ximp_XIM)NULL) { ! return((XIM)NULL); } ! im->methods = &Ximp_im_methods; - im->core.lcd = lcd; - im->core.ic_chain = (XIC)NULL; - im->core.display = dpy; - im->core.rdb = rdb; - im->core.res_name = res_name; - im->core.res_class = res_class; ! if((ximp_impart = (XIMXimpRec *)Xmalloc(sizeof(XIMXimpRec))) == (XIMXimpRec *)NULL) { ! Xfree(im); ! return((XIM)NULL); } ! ximp_impart->connectserver = 0; ! ximp_impart->inputserver = 1; ! ximp_impart->use_wchar = False; ! ximp_impart->process_start_keys = NULL; ! im->ximp_impart = ximp_impart; ! ! if(_Ximp_OpenIM_Resource(im) == True) ! im->ximp_impart->inputserver = 0; ! if(_Ximp_Setup(im) == False && im->ximp_impart->inputserver) { ! Xfree(ximp_impart); ! Xfree(im); ! return((XIM)NULL); } ! return((XIM)im); } ! static char * ! _Ximp_GetIMValues(im, values) ! Ximp_XIM im; ! XIMArg *values; { ! XIMArg *p; ! for(p = values; p->name != NULL; p++) { ! if(strcmp(p->name, XNQueryInputStyle) == 0) { ! if( _Ximp_GetStyle(im, p->value) == False ) ! break; ! } ! else { ! if( _Ximp_GetIMExtension(im, p->name, p->value) == False ) ! break; ! } } ! return(p->name); } static Status _Ximp_CloseIM(im) ! Ximp_XIM im; { ! XIC ic; ! int i; ! XIMXimpRec *ximp_impart; ! ! for(ic = im->core.ic_chain; ic; ic = ic->core.next) ! XDestroyIC(ic); ! ximp_impart = (XIMXimpRec *)im->ximp_impart; ! if( ximp_impart->process_start_keys ) { ! XFree( ximp_impart->process_start_keys->keys_list ); ! XFree( ximp_impart->process_start_keys ); } ! for(i=0; i < Ximp_Xim_count; i++) { ! if(Ximp_Xim_List[i] == im) { ! Ximp_Xim_List[i] = NULL; ! break; ! } ! } ! if(ximp_impart->connectserver) { ! _Ximp_SetupFreeExtension(im); ! _Ximp_SetupFree(ximp_impart->im_proto_vl, ! ximp_impart->im_styles, ! ximp_impart->im_keyslist, ! ximp_impart->im_server_name, ! ximp_impart->im_server_vl, ! ximp_impart->im_vendor_name, ! ximp_impart->im_ext_list); ! } ! Xfree(ximp_impart); ! return(True); } - static char IMname[XIMP_NAME]; - static char LCname[XIMP_NAME]; - Bool ! _Ximp_Setup(im) ! Ximp_XIM im; { ! XLCd lcd; ! Atom atom_server; ! Window fe_window_id; ! Display *dpy; ! Atom improtocol_id, ! version_id, style_id, keys_id, servername_id, ! serverversion_id, vendorname_id, extentions_id, ! ctext_id, focus_win_id, preedit_atr_id, status_atr_id, ! preeditfont_id, statusfont_id, preeditmaxsize_id; ! char *version; ! XIMStyles *imstyle; ! Ximp_KeyList *keylist; ! Atom *ext_list; ! char *server_name; ! char *server_vl; ! char *vendor_name; ! Atom actual_type; ! int actual_format; ! unsigned long nitems, bytes_after; ! char *prop; ! long *prop_long; ! int *prop_int; ! int i, n, count; ! lcd = im->core.lcd; ! dpy = im->core.display; ! strcpy(LCname, lcd->core.name); ! prop = index(LCname, '.'); ! #ifdef sun /* XXX */ ! if (!strcmp(LCname, "japanese")) ! strcpy(LCname, "ja_JP"); ! #endif ! if (prop) ! *prop = 0; ! /* IMserver Name ex. _XIMP_ja_JP */ ! if(lcd->core.modifiers == (char *)NULL || *lcd->core.modifiers == '\0') ! sprintf(IMname, "%s%s", _XIMP_BASE, LCname); /* Default */ ! else { ! #define MODIFIER "@im=" ! char *mod, *s, buf[20]; ! ! (void)strcpy(IMname, _XIMP_BASE); ! (void)strcat(IMname, LCname); ! mod = _Ximp_Strstr(lcd->core.modifiers, MODIFIER); ! if (mod) { ! (void)strcat(IMname, "@"); ! mod += strlen(MODIFIER); ! s = IMname + strlen(IMname); ! while (*mod && *mod != '@') { ! *s++ = *mod++; ! } ! *s = '\0'; ! } ! (void)sprintf(buf, ".%d", dpy->default_screen); ! (void)strcat(IMname, buf); } ! #undef MODIFIER ! /* Get IMS Window WID */ ! if((atom_server = XInternAtom(dpy, IMname, False)) == (Atom)NULL){ ! return(False); } ! fe_window_id = XGetSelectionOwner(dpy, atom_server); ! if(fe_window_id == NULL) return(False); ! ! /* Get Property : _XIMP_VERSION */ ! version_id = XInternAtom(dpy, _XIMP_VERSION, False); ! if( XGetWindowProperty(dpy, fe_window_id, version_id, 0L, 1000000L, False, ! XA_STRING, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop)) != Success) return(False); ! if((version = Xmalloc((sizeof(char) * nitems + 1))) == NULL) { ! XFree(prop); return(False); ! } ! strncpy(version, prop, nitems); ! version[nitems] = '\0'; ! XFree(prop); ! ! /* Get Property : _XIMP_STYLE */ ! style_id = XInternAtom(dpy, _XIMP_STYLE, False); ! if( XGetWindowProperty(dpy, fe_window_id, style_id, 0L, 1000000L, False, ! style_id, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop_long)) != Success) { ! _Ximp_SetupFree(version, NULL, NULL, NULL, NULL, NULL, NULL); return(False); } ! if((imstyle = (XIMStyles *)Xmalloc(sizeof(XIMStyles))) == NULL) { ! _Ximp_SetupFree(version, NULL, NULL, NULL, NULL, NULL, NULL); ! XFree((XPointer)prop_long); ! return(False); } ! if((imstyle->supported_styles = ! (XIMStyle *)Xmalloc(sizeof(XIMStyle) * nitems)) == NULL) { ! Xfree(imstyle); ! _Ximp_SetupFree(version, NULL, NULL, NULL, NULL, NULL, NULL); ! XFree((XPointer)prop_long); ! return(False); } ! for(i=0; i < nitems; i++) { ! imstyle->supported_styles[i] = prop_long[i]; } ! imstyle->count_styles = nitems; ! XFree((XPointer)prop_long); ! ! /* Get Property : _XIMP_KEYS */ keys_id = XInternAtom(dpy, _XIMP_KEYS, False); if( XGetWindowProperty(dpy, fe_window_id, keys_id, 0L, 1000000L, False, ! keys_id, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop_int)) != Success) { ! _Ximp_SetupFree(version, imstyle, NULL, NULL, NULL, NULL, NULL); ! return(False); } if((keylist = (Ximp_KeyList *)Xmalloc(sizeof(Ximp_KeyList))) == NULL) { ! _Ximp_SetupFree(version, imstyle, NULL, NULL, NULL, NULL, NULL); ! XFree((XPointer)prop_int); ! return(False); } count = nitems / 3; if((keylist->keys_list = (Ximp_Key *)Xmalloc(sizeof(Ximp_Key) * count)) == NULL) { ! Xfree(keylist); ! _Ximp_SetupFree(version, imstyle, NULL, NULL, NULL, NULL, NULL); ! XFree((XPointer)prop_int); ! return(False); } for(i=0,n=0; n < count; n++) { ! keylist->keys_list[n].modifier = prop_int[i++]; ! keylist->keys_list[n].modifier_mask = prop_int[i++]; ! keylist->keys_list[n].keysym = prop_int[i++]; } keylist->count_keys = count; XFree((XPointer)prop_int); ! ! /* Get Property : _XIMP_SERVERNAME */ ! servername_id = XInternAtom(dpy, _XIMP_SERVERNAME, False); ! if( XGetWindowProperty(dpy, fe_window_id, servername_id, 0L, 1000000L, False, ! XA_STRING, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop)) != Success) { ! _Ximp_SetupFree(version, imstyle, keylist, NULL, NULL, NULL, NULL); ! return(False); ! } ! if((server_name = (char *)Xmalloc((sizeof(char) * nitems + 1))) == NULL) { ! _Ximp_SetupFree(version, imstyle, keylist, NULL, NULL, NULL, NULL); ! XFree(prop); ! return(False); ! } ! strncpy(server_name, prop, nitems); ! server_name[nitems] = '\0'; XFree(prop); ! ! /* Get Property : _XIMP_SERVERVERSION */ ! serverversion_id = XInternAtom(dpy, _XIMP_SERVERVERSION, False); ! if( XGetWindowProperty(dpy, fe_window_id, serverversion_id, 0L, 1000000L, False, ! XA_STRING, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop)) != Success) { ! _Ximp_SetupFree(version, imstyle, keylist, server_name, NULL, NULL, NULL); ! return(False); ! } ! if((server_vl = (char *)Xmalloc((sizeof(char) * nitems + 1))) == NULL) { ! _Ximp_SetupFree(version, imstyle, keylist, server_name, NULL, NULL, NULL); ! XFree(prop); ! return(False); ! } ! strncpy(server_vl, prop, nitems); ! server_vl[nitems] = '\0'; XFree(prop); ! ! /* Get Property : _XIMP_VENDORNAME */ ! vendorname_id = XInternAtom(dpy, _XIMP_VENDORNAME, False); ! if( XGetWindowProperty(dpy, fe_window_id, vendorname_id, 0L, 1000000L, False, ! XA_STRING, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop)) != Success) { ! _Ximp_SetupFree(version, imstyle, keylist, server_name, NULL, NULL, NULL); ! return(False); ! } ! if((vendor_name = (char *)Xmalloc((sizeof(char) * nitems + 1))) == NULL) { ! _Ximp_SetupFree(version, imstyle, keylist, server_name, NULL, NULL, NULL); ! XFree(prop); ! return(False); ! } ! strncpy(vendor_name, prop, nitems); ! vendor_name[nitems] = '\0'; XFree(prop); ! /* Get Property : _XIMP_EXTENSIONS */ ! extentions_id = XInternAtom(dpy, _XIMP_EXTENSIONS, False); ! if( XGetWindowProperty(dpy, fe_window_id, extentions_id, 0L, 1000000L, False, ! extentions_id, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop_int)) != Success) { ! _Ximp_SetupFree(version, imstyle, keylist, server_name, server_vl, vendor_name, NULL); ! return(False); ! } ! if((ext_list = (Atom *)Xmalloc((sizeof(Atom) * (nitems + 1)))) == NULL) { ! _Ximp_SetupFree(version, imstyle, keylist, server_name, server_vl, vendor_name, NULL); ! if( prop_int ) ! XFree((XPointer)prop_int); ! return(False); ! } ! for(i=0; i < nitems; i++) ! ext_list[i] = prop_int[i]; ! ext_list[nitems] = NULL; ! if( prop_int ) ! XFree((XPointer)prop_int); ! im->ximp_impart->fe_window = fe_window_id; ! Protocol_ID = XInternAtom(dpy, _XIMP_PROTOCOL, False); ! im->ximp_impart->improtocol_id = Protocol_ID; ! im->ximp_impart->version_id = version_id; ! im->ximp_impart->style_id = style_id; ! im->ximp_impart->keys_id = keys_id; ! im->ximp_impart->servername_id = servername_id; ! im->ximp_impart->serverversion_id = serverversion_id; ! im->ximp_impart->vendorname_id = vendorname_id; ! im->ximp_impart->extentions_id = extentions_id; ! im->ximp_impart->ctext_id = XInternAtom(dpy, _XIMP_CTEXT, False); ! im->ximp_impart->focus_win_id = XInternAtom(dpy, _XIMP_FOCUS, False); ! im->ximp_impart->preedit_atr_id = XInternAtom(dpy, _XIMP_PREEDIT, False); ! im->ximp_impart->status_atr_id = XInternAtom(dpy, _XIMP_STATUS, False); ! im->ximp_impart->preeditfont_id = XInternAtom(dpy, _XIMP_PREEDITFONT, False); ! im->ximp_impart->statusfont_id = XInternAtom(dpy, _XIMP_STATUSFONT, False); ! im->ximp_impart->preeditmaxsize_id = XInternAtom(dpy, _XIMP_PREEDITMAXSIZE, False); ! im->ximp_impart->im_proto_vl = version; ! im->ximp_impart->im_styles = imstyle;; ! im->ximp_impart->im_keyslist = keylist; ! im->ximp_impart->im_server_name = server_name; ! im->ximp_impart->im_server_vl = server_vl; ! im->ximp_impart->im_vendor_name = vendor_name; ! im->ximp_impart->im_ext_list = ext_list; ! if(Ximp_Xim_List == (Ximp_XIM *)NULL){ ! Ximp_Xim_List = (Ximp_XIM *)Xmalloc(sizeof(Ximp_XIM)); ! if( Ximp_Xim_List == NULL ) { ! _Ximp_SetupFree(version, imstyle, keylist, server_name, server_vl, vendor_name, NULL); ! return( False ); ! } ! Ximp_Xim_List[0] = im; ! Ximp_Xim_count = 1; } ! else { ! Ximp_XIM *ximp_xim; ! n = 0; ! for(i=0; i < Ximp_Xim_count; i++) { ! if( Ximp_Xim_List[i] == im ) { ! n = 1; ! break; ! } ! if(Ximp_Xim_List[i] == NULL) { ! Ximp_Xim_List[i] = im; ! n = 1; ! break; ! } ! } ! if(n == 0) { ! ximp_xim = (Ximp_XIM *)Xrealloc(Ximp_Xim_List, ((i + 1) * sizeof(Ximp_XIM))); ! if( ximp_xim == NULL ) { ! _Ximp_SetupFree(version, imstyle, keylist, server_name, server_vl, vendor_name, NULL); ! return( False ); ! } ! Ximp_Xim_List = ximp_xim; ! Ximp_Xim_List[Ximp_Xim_count] = im; ! Ximp_Xim_count++; ! } ! } ! ! _Ximp_SetupExtension(im); ! ! _XRegisterFilterByType(im->core.display, fe_window_id, ! DestroyNotify, DestroyNotify, ! _Ximp_XimFilter_Destroy, NULL); ! XSelectInput(im->core.display, fe_window_id, StructureNotifyMask); ! ! im->ximp_impart->connectserver = 1; ! return(True); } int ! _Ximp_SetupFree(proto_vl, style_list, keys_list, server_name, server_vl, ! vendor_name, ext_list) ! char *proto_vl; ! XIMStyles *style_list; ! Ximp_KeyList *keys_list; ! char *server_name; ! char *server_vl; ! char *vendor_name; ! Atom *ext_list; ! { ! if(proto_vl) ! Xfree(proto_vl); ! if(style_list) { ! Xfree(style_list->supported_styles); ! Xfree(style_list); ! } ! if(keys_list) { ! Xfree(keys_list->keys_list); ! Xfree(keys_list); ! } ! if(server_name) ! Xfree(server_name); ! if(server_vl) ! Xfree(server_vl); ! if(vendor_name) ! Xfree(vendor_name); ! if(ext_list) ! Xfree(ext_list); ! } ! ! Ximp_XIC ! _Ximp_LookupXIC(icid) ! int icid; { ! int i; ! Ximp_XIM pim; ! Ximp_XIC pic; ! ! for(i = 0; i < Ximp_Xim_count; i++) { ! if( (pim = Ximp_Xim_List[i]) == NULL ) ! continue; ! for(pic = (Ximp_XIC)pim->core.ic_chain; pic; pic = (Ximp_XIC)pic->core.next) { ! if(pic->ximp_icpart->icid == icid) ! return(pic); ! } ! } ! return(NULL); } static Bool _Ximp_GetStyle(im, p_style) ! Ximp_XIM im; ! XIMStyles **p_style; { ! XIMStyles *p; ! int i; ! if(!(im->ximp_impart->connectserver)) { ! *p_style = (XIMStyles *)NULL; ! return(False); ! } p = im->ximp_impart->im_styles; ! if((*p_style = (XIMStyles *)Xmalloc(sizeof(XIMStyles) ! + p->count_styles * sizeof(XIMStyle))) == NULL) ! return(False); ! (*p_style)->count_styles = p->count_styles; ! (*p_style)->supported_styles = (XIMStyle *)((char *)*p_style + sizeof(XIMStyles)); ! for(i=0; i < (int)p->count_styles; i++) { ! (*p_style)->supported_styles[i] = p->supported_styles[i]; ! } ! return(True); } ! Atom ! _Ximp_Protocol_id() { ! return(Protocol_ID); } --- 39,773 ---- #include "Xlcint.h" #include "Ximplc.h" + #include + #ifndef isdigit + #define isdigit(c) (0x30<=(c) && (c)<=0x39) + #endif /* !isdigit */ + static Status _Ximp_CloseIM(); static char *_Ximp_GetIMValues(); extern XIC _Ximp_CreateIC(); ! extern void _Ximp_OpenIM_Resource(); extern Ximp_XIC _Ximp_LookupXIC(); extern int _Ximp_SetupFree(); ! extern void _Ximp_Local_OpenIM_hook(); extern void _Ximp_SetupExtension(); extern Bool _Ximp_GetIMExtension(); extern Bool _Ximp_XimFilter_Destroy(); + extern FILE *_XlcOpenLocaleFile(); + Ximp_XIM *Ximp_Xim_List = (Ximp_XIM *)NULL; int Ximp_Xim_count = 0; ! static Atom Protocol_ID = 0; ! static XIMMethodsRec Ximp_im_methods = { ! _Ximp_CloseIM, /* close */ ! _Ximp_GetIMValues, /* get_values */ ! _Ximp_CreateIC, /* create_ic */ ! }; ! extern XIMMethodsRec Ximp_local_im_methods; ! ! char * ! _Ximp_Strstr(src, dest) register char *src, *dest; { register len; ! ! if(!src || !dest) return( NULL ); len = strlen(dest); ! while(src = index(src, *dest)) { ! if(strncmp(src, dest, len) == 0) ! return(src); src++; } ! return(NULL); } ! Ximp_XIC ! _Ximp_LookupXIC(icid) ! int icid; { ! int i; ! Ximp_XIM pim; ! Ximp_XIC pic; ! ! for(i = 0; i < Ximp_Xim_count; i++) { ! if((pim = Ximp_Xim_List[i]) == NULL) continue ; ! for(pic = (Ximp_XIC)pim->core.ic_chain; pic; pic = (Ximp_XIC)pic->core.next) { ! if(pic->ximp_icpart->icid == icid) ! return(pic); ! } ! } ! return(NULL); ! } ! Atom ! _Ximp_Protocol_id() ! { ! return(Protocol_ID); ! } ! ! static int ! _Ximp_vl2vnum (version) ! register char *version; ! { ! char p[1024]; ! register char *q; ! register int l = strlen(version); ! register int i; ! Bool hyphen = False; ! Bool u_score = False; ! ! q = p; ! for (i = 0;i < l;i++){ ! if(isdigit(*version)) { ! *q = *version; ! q++; ! } else if(*version == '_') { ! u_score = True; ! } else if(*version == '-') { ! hyphen = True; } + version++; + } + p[l] = '\n'; + if(u_score) { + return (atoi(p) + 100); + } else if(hyphen) { + return (atoi(p) + 200); + } else { + return(atoi(p)); + } + } ! static Bool ! _Ximp_IMList(im) ! Ximp_XIM im; ! { ! int n, i = 0; ! Ximp_XIM *ximp_xim; ! if( Ximp_Xim_List == (Ximp_XIM *)NULL ) { ! if( (Ximp_Xim_List = (Ximp_XIM *)Xmalloc(sizeof(Ximp_XIM))) == NULL ) { ! return( False ); } ! Ximp_Xim_List[0] = im; ! Ximp_Xim_count = 1; ! } ! else { ! n = 0; ! for( i = 0; i < Ximp_Xim_count; i++ ) { ! if( Ximp_Xim_List[i] == NULL ) { ! Ximp_Xim_List[i] = im; ! n = 1; ! break; ! } } ! if( n == 0 ) { ! if( (ximp_xim = (Ximp_XIM *)Xrealloc( Ximp_Xim_List, ((i + 1) * sizeof(Ximp_XIM)))) == NULL ) { ! return( False ); ! } ! Ximp_Xim_List = ximp_xim; ! Ximp_Xim_List[Ximp_Xim_count] = im; ! Ximp_Xim_count++; ! } ! } ! return( True ); } ! XIM ! _Ximp_OpenIM(lcd, dpy, rdb, res_name, res_class) ! XLCd lcd; ! Display *dpy; ! XrmDatabase rdb; ! char *res_name, *res_class; { ! Ximp_XIM im; ! XIMXimpRec *ximp_impart; ! Bool success; ! char *mod, buf[128]; ! int i; ! ! if((im = (Ximp_XIM)Xmalloc(sizeof(Ximp_XIMRec))) == (Ximp_XIM)NULL) { ! return((XIM)NULL); ! } ! if((ximp_impart = (XIMXimpRec *)Xmalloc(sizeof(XIMXimpRec))) == (XIMXimpRec *)NULL) { ! Xfree(im); ! return((XIM)NULL); ! } ! bzero(im, sizeof(Ximp_XIMRec)); ! bzero(ximp_impart, sizeof(XIMXimpRec)); ! im->ximp_impart = ximp_impart; ! ! im->methods = &Ximp_im_methods; ! im->core.lcd = lcd; ! im->core.ic_chain = (XIC)NULL; ! im->core.display = dpy; ! im->core.rdb = rdb; ! im->core.res_name = res_name; ! im->core.res_class = res_class; ! ! ximp_impart->is_local = False; ! ximp_impart->reconnection_mode = XIMP_NOCONNECT; ! ximp_impart->is_connected = False; ! ximp_impart->im_name = (char *)NULL; ! ximp_impart->process_start_keys = (Ximp_KeyList *)NULL; ! ximp_impart->use_wchar = False; ! ximp_impart->delaybind_styles = (XIMStyles *)NULL; ! ximp_impart->current_ic = (XIC)NULL; ! ! buf[0] = '\0'; ! i = 0; ! if( lcd->core.modifiers != (char *)NULL && *lcd->core.modifiers != '\0' ) { ! #define MODIFIER "@im=" ! mod = _Ximp_Strstr( lcd->core.modifiers, MODIFIER ); ! if( mod ) { ! mod += strlen( MODIFIER ); ! while( *mod && *mod != '@' ) { ! buf[i++] = *mod++; ! } ! buf[i] = '\0'; } ! } ! #undef MODIFIER ! if((ximp_impart->im_name = Xmalloc(i+1)) == NULL) ! goto Set_Error; ! strcpy(ximp_impart->im_name, buf); ! ! if( !_Ximp_IMList(im) ) ! goto Set_Error; ! ! _Ximp_OpenIM_Resource( im ); ! ! if( strcmp( ximp_impart->im_name, "" ) == 0 ) { ! FILE *fp; ! fp = _XlcOpenLocaleFile( NULL, ((XimpLCd)im->core.lcd)->locale.language, COMPOSE_FILE ); ! if( fp != NULL ) { ! fclose( fp ); ! IS_LOCAL_PROCESSING(im) = True; ! } ! } else if( strcmp( im->ximp_impart->im_name, "local" ) == 0 || ! strcmp( im->ximp_impart->im_name, "none" ) == 0 ) { ! IS_LOCAL_PROCESSING(im) = True; ! } ! ! if( IS_LOCAL_PROCESSING(im) ) { ! if( !_Ximp_LocalConnect(im) ) ! goto Set_Error; ! } ! else { ! if( !_Ximp_ConnectServer(im) ) { ! if( !(IS_DELAYBINDABLE(im)) ) ! goto Set_Error; ! } ! } ! ! return((XIM)im); ! ! Set_Error : ! if( ximp_impart->delaybind_styles ) ! Xfree( ximp_impart->delaybind_styles ); ! Xfree( ximp_impart ); ! Xfree( im ); ! return( NULL ); } static Status _Ximp_CloseIM(im) ! Ximp_XIM im; { ! XIC ic; ! int i; ! XIMXimpRec *ximp_impart; ! ! while( ic = im->core.ic_chain ) ! XDestroyIC(ic); ! ximp_impart = (XIMXimpRec *)im->ximp_impart; ! if(ximp_impart->process_start_keys) { ! XFree( ximp_impart->process_start_keys->keys_list ); ! XFree( ximp_impart->process_start_keys ); ! } ! if( ximp_impart->im_name ) ! XFree( ximp_impart->im_name ); ! for(i=0; i < Ximp_Xim_count; i++) { ! if(Ximp_Xim_List[i] == im) { ! Ximp_Xim_List[i] = NULL; ! break; } ! } ! if(IS_SERVER_CONNECTED(im)){ ! _Ximp_SetupFreeExtension(im); ! _Ximp_SetupFree(ximp_impart->im_proto_vl, ! ximp_impart->im_styles, ! ximp_impart->type_list, ! ximp_impart->im_keyslist, ! ximp_impart->im_offkeyslist, ! ximp_impart->im_server_name, ! ximp_impart->im_server_vl, ! ximp_impart->im_vendor_name, ! ximp_impart->im_ext_list); ! } ! if( ximp_impart->delaybind_styles ) ! Xfree( ximp_impart->delaybind_styles ); ! Xfree(ximp_impart); ! return(True); } Bool ! _Ximp_ConnectServer( im ) ! Ximp_XIM im; { ! char IMname[XIMP_NAME]; ! char LCname[XIMP_NAME]; ! XLCd lcd; ! Atom atom_server; ! Window fe_window_id; ! Display *dpy; ! Atom improtocol_id, type_id, off_keys_id, ! version_id, style_id, keys_id, servername_id, ! serverversion_id, vendorname_id, extentions_id, ! ctext_id, focus_win_id, preedit_atr_id, status_atr_id, ! preeditfont_id, statusfont_id, preeditmaxsize_id; ! char *version; ! XIMStyles *imstyle; ! Ximp_KeyList *keylist; ! Ximp_KeyList *offkeylist = NULL; ! long *type_list; ! Atom *ext_list; ! char *server_name; ! char *server_vl; ! char *vendor_name; ! Atom actual_type; ! int actual_format; ! unsigned long nitems, bytes_after; ! char *prop; ! long *prop_long; ! int *prop_int; ! int i, n, count; ! Ximp_XIM *ximp_xim; ! char *language, *territory; ! lcd = im->core.lcd; ! dpy = im->core.display; ! language = ((XimpLCd) lcd)->locale.language; ! territory = ((XimpLCd) lcd)->locale.territory; ! if (*territory) ! sprintf(LCname, "%s_%s", language, territory); ! else ! strcpy(LCname, language); ! ! /* IMserver Name ex. _XIMP_ja_JP */ ! if(lcd->core.modifiers == (char *)NULL || *lcd->core.modifiers == '\0') ! sprintf(IMname, "%s%s", _XIMP_BASE, LCname); /* Default */ ! else { ! char buf[20]; ! ! strcpy(IMname, _XIMP_BASE); ! strcat(IMname, LCname); ! strcat( IMname, "@" ); ! strcat( IMname, im->ximp_impart->im_name ); ! sprintf(buf, ".%d", dpy->default_screen); ! strcat(IMname, buf); ! } ! /* Get IMS Window WID */ ! if((atom_server = XInternAtom(dpy, IMname, False)) == (Atom)NULL){ ! return(False); ! } ! fe_window_id = XGetSelectionOwner(dpy, atom_server); ! if(fe_window_id == NULL) { ! return(False); ! } ! /* Get Property : _XIMP_VERSION */ ! version_id = XInternAtom(dpy, _XIMP_VERSION, False); ! if(XGetWindowProperty(dpy, fe_window_id, version_id, 0L, 1000000L, False, ! XA_STRING, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop)) != Success) ! return(False); ! if((version = Xmalloc((sizeof(char) * nitems + 1))) == NULL){ ! XFree((XPointer)prop); ! return(False); ! } ! strncpy(version, prop, nitems); ! version[nitems] = '\0'; ! XFree(prop); ! im->ximp_impart->im_proto_vnum = _Ximp_vl2vnum(version); ! ! /* Get Property : _XIMP_STYLE */ ! style_id = XInternAtom(dpy, _XIMP_STYLE, False); ! if( XGetWindowProperty(dpy, fe_window_id, style_id, 0L, 1000000L, False, ! style_id, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop_long)) != Success) { ! _Ximp_SetupFree(version, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); ! return(False); ! } ! if((imstyle = (XIMStyles *)Xmalloc(sizeof(XIMStyles))) == NULL) { ! _Ximp_SetupFree(version, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); ! XFree((XPointer)prop_long); ! return(False); ! } ! if((imstyle->supported_styles = ! (XIMStyle *)Xmalloc(sizeof(XIMStyle) * nitems)) == NULL) { ! Xfree(imstyle); ! _Ximp_SetupFree(version, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); ! XFree((XPointer)prop_long); ! return(False); ! } ! for(i=0; i < nitems; i++) { ! imstyle->supported_styles[i] = prop_long[i]; ! } ! imstyle->count_styles = nitems; ! XFree((XPointer)prop_long); ! ! /* Get Property : _XIMP_TYPE for Ximp4.0 */ ! if(ISXimp4IM(im)){ ! type_id = XInternAtom(dpy, _XIMP_TYPE, False); ! if( XGetWindowProperty(dpy, fe_window_id, type_id, 0L, 1000000L, False, ! type_id, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop_long)) != Success) { ! _Ximp_SetupFree(version, imstyle, NULL, NULL, NULL, NULL, NULL, NULL, NULL); ! XFree((XPointer)prop_long); ! return(False); } ! if((type_list = (long *)Xmalloc(sizeof(long) * (nitems + 1))) == NULL) { ! _Ximp_SetupFree(version, imstyle, NULL, NULL, NULL, NULL, NULL, NULL, NULL); ! XFree((XPointer)prop_long); ! return(False); } ! for(i = 0; i < nitems; i++) { ! type_list[i] = prop_long[i]; ! } ! type_list[nitems] = NULL; ! XFree((XPointer)prop_long); ! } else { ! type_list = NULL; /* For save _Ximp_SetupFree() */ ! } ! ! /* ! *Get Property : ! *_XIMP_SPROC_STARTED_KEYS and _XIMP_SPROC_STOPPED_KEYS(Ximp4.0) ! *_XIMP_KEYS(Ximp3.5) ! */ ! if(ISXimp4IM(im)){ ! if(im->ximp_impart->im_keyslist){ ! /* ! * if this is reconnected, this field must be remaining. ! * BIG assumption: always same server will be reconnected! ! */ ! keylist = im->ximp_impart->im_keyslist ; ! } else { ! keys_id = XInternAtom(dpy, _XIMP_SPROC_STARTED_KEYS, False); ! if( XGetWindowProperty(dpy, fe_window_id, keys_id, 0L, 1000000L, False, ! keys_id, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop_int)) != Success) { ! _Ximp_SetupFree(version, imstyle, type_list, NULL, NULL, NULL, NULL, NULL, NULL); return(False); ! } ! if((keylist = (Ximp_KeyList *)Xmalloc(sizeof(Ximp_KeyList))) == NULL) { ! _Ximp_SetupFree(version, imstyle, type_list, NULL, NULL, NULL, NULL, NULL, NULL); ! XFree( (XPointer)prop_int ); return(False); ! } ! count = nitems / 3; ! if((keylist->keys_list = (Ximp_Key *)Xmalloc(sizeof(Ximp_Key) * count)) == NULL) { ! Xfree(keylist); ! _Ximp_SetupFree(version, imstyle, type_list, NULL, NULL, NULL, NULL, NULL, NULL); ! XFree( (XPointer)prop_int ); return(False); + } + for(i=0,n=0; n < count; n++) { + keylist->keys_list[n].modifier = prop_int[i++]; + keylist->keys_list[n].modifier_mask = prop_int[i++]; + keylist->keys_list[n].keysym = prop_int[i++]; + } + keylist->count_keys = count; + XFree((XPointer)prop_int); } ! off_keys_id = XInternAtom(dpy, _XIMP_SPROC_STOPPED_KEYS, False); ! if( XGetWindowProperty(dpy, fe_window_id, off_keys_id, 0L, 1000000L, False, ! off_keys_id, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop_int)) != Success) { ! _Ximp_SetupFree(version, imstyle, type_list, keylist, NULL, NULL, NULL, NULL, NULL); ! XFree( (XPointer)prop_int ); ! return(False); } ! if((offkeylist = (Ximp_KeyList *)Xmalloc(sizeof(Ximp_KeyList))) == NULL) { ! _Ximp_SetupFree(version, imstyle, type_list, keylist, NULL, NULL, NULL, NULL, NULL); ! XFree( (XPointer)prop_int ); ! return(False); } ! count = nitems / 3; ! if((offkeylist->keys_list = (Ximp_Key *)Xmalloc(sizeof(Ximp_Key) * count)) == NULL) { ! Xfree(offkeylist); ! XFree( (XPointer)prop_int ); ! _Ximp_SetupFree(version, imstyle, type_list, keylist, NULL, NULL, NULL, NULL, NULL); ! return(False); } ! for(i=0,n=0; n < count; n++) { ! offkeylist->keys_list[n].modifier = prop_int[i++]; ! offkeylist->keys_list[n].modifier_mask = prop_int[i++]; ! offkeylist->keys_list[n].keysym = prop_int[i++]; ! } ! offkeylist->count_keys = count; ! XFree((XPointer)prop_int); ! } else { /* Ximp3.5 */ keys_id = XInternAtom(dpy, _XIMP_KEYS, False); if( XGetWindowProperty(dpy, fe_window_id, keys_id, 0L, 1000000L, False, ! keys_id, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop_int)) != Success) { ! _Ximp_SetupFree(version, imstyle, type_list, NULL, NULL, NULL, NULL, NULL, NULL); ! return(False); } if((keylist = (Ximp_KeyList *)Xmalloc(sizeof(Ximp_KeyList))) == NULL) { ! _Ximp_SetupFree(version, imstyle, type_list, NULL, NULL, NULL, NULL, NULL, NULL); ! XFree( (XPointer)prop_int ); ! return(False); } count = nitems / 3; if((keylist->keys_list = (Ximp_Key *)Xmalloc(sizeof(Ximp_Key) * count)) == NULL) { ! Xfree(keylist); ! XFree( (XPointer)prop_int ); ! _Ximp_SetupFree(version, imstyle, type_list, NULL, NULL, NULL, NULL, NULL, NULL); ! return(False); } for(i=0,n=0; n < count; n++) { ! keylist->keys_list[n].modifier = prop_int[i++]; ! keylist->keys_list[n].modifier_mask = prop_int[i++]; ! keylist->keys_list[n].keysym = prop_int[i++]; } keylist->count_keys = count; XFree((XPointer)prop_int); ! } ! /* Get Property : _XIMP_SERVERNAME */ ! servername_id = XInternAtom(dpy, _XIMP_SERVERNAME, False); ! if( XGetWindowProperty(dpy, fe_window_id, servername_id, 0L, 1000000L, False, ! XA_STRING, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop)) != Success) { ! _Ximp_SetupFree(version, imstyle, type_list, keylist, offkeylist, NULL, NULL, NULL, NULL); ! return(False); ! } ! if((server_name = (char *)Xmalloc((sizeof(char) * nitems + 1))) == NULL) { ! _Ximp_SetupFree(version, imstyle, type_list, keylist, offkeylist, NULL, NULL, NULL, NULL); XFree(prop); ! return(False); ! } ! strncpy(server_name, prop, nitems); ! server_name[nitems] = '\0'; ! XFree(prop); ! ! /* Get Property : _XIMP_SERVERVERSION */ ! serverversion_id = XInternAtom(dpy, _XIMP_SERVERVERSION, False); ! if( XGetWindowProperty(dpy, fe_window_id, serverversion_id, 0L, 1000000L, False, ! XA_STRING, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop)) != Success) { ! _Ximp_SetupFree(version, imstyle, type_list, keylist, offkeylist, server_name, NULL, NULL, NULL); ! return(False); ! } ! if((server_vl = (char *)Xmalloc((sizeof(char) * nitems + 1))) == NULL) { ! _Ximp_SetupFree(version, imstyle, type_list, keylist, offkeylist, server_name, NULL, NULL, NULL); XFree(prop); ! return(False); ! } ! strncpy(server_vl, prop, nitems); ! server_vl[nitems] = '\0'; ! XFree(prop); ! ! /* Get Property : _XIMP_VENDORNAME */ ! vendorname_id = XInternAtom(dpy, _XIMP_VENDORNAME, False); ! if( XGetWindowProperty(dpy, fe_window_id, vendorname_id, 0L, 1000000L, False, ! XA_STRING, &actual_type, &actual_format, &nitems, ! &bytes_after, (unsigned char **)(&prop)) != Success) { ! _Ximp_SetupFree(version, imstyle, type_list, keylist, offkeylist, server_name, server_vl, NULL, NULL); ! return(False); ! } ! if((vendor_name = (char *)Xmalloc((sizeof(char) * nitems + 1))) == NULL) { ! _Ximp_SetupFree(version, imstyle, type_list, keylist, offkeylist, server_name, server_vl, NULL, NULL); XFree(prop); + return(False); + } + strncpy(vendor_name, prop, nitems); + vendor_name[nitems] = '\0'; + XFree(prop); + + /* Get Property : _XIMP_EXTENSIONS */ + extentions_id = XInternAtom(dpy, _XIMP_EXTENSIONS, False); + if( XGetWindowProperty(dpy, fe_window_id, extentions_id, 0L, 1000000L, False, + extentions_id, &actual_type, &actual_format, &nitems, + &bytes_after, (unsigned char **)(&prop_int)) != Success) { + _Ximp_SetupFree(version, imstyle, type_list, keylist, offkeylist, server_name, server_vl, vendor_name, NULL); + return(False); + } + if((ext_list = (Atom *)Xmalloc((sizeof(Atom) * (nitems + 1)))) == NULL) { + _Ximp_SetupFree(version, imstyle, type_list, keylist, offkeylist, server_name, server_vl, vendor_name, NULL); + if(prop_int) XFree((XPointer)prop_int); + return(False); + } + for(i=0; i < nitems; i++) + ext_list[i] = prop_int[i]; + ext_list[nitems] = NULL; + if(prop_int) XFree((XPointer)prop_int); + + im->ximp_impart->fe_window = fe_window_id; + Protocol_ID = XInternAtom(dpy, _XIMP_PROTOCOL, False); + im->ximp_impart->improtocol_id = Protocol_ID; + im->ximp_impart->version_id = version_id; + im->ximp_impart->style_id = style_id; + im->ximp_impart->keys_id = keys_id; + im->ximp_impart->servername_id = servername_id; + im->ximp_impart->serverversion_id = serverversion_id; + im->ximp_impart->vendorname_id = vendorname_id; + im->ximp_impart->extentions_id = extentions_id; + im->ximp_impart->ctext_id = XInternAtom(dpy, _XIMP_CTEXT, False); + im->ximp_impart->focus_win_id = XInternAtom(dpy, _XIMP_FOCUS, False); + im->ximp_impart->preedit_atr_id = XInternAtom(dpy, _XIMP_PREEDIT, False); + im->ximp_impart->status_atr_id = XInternAtom(dpy, _XIMP_STATUS, False); + im->ximp_impart->preeditfont_id = XInternAtom(dpy, _XIMP_PREEDITFONT, False); + im->ximp_impart->statusfont_id = XInternAtom(dpy, _XIMP_STATUSFONT, False); + im->ximp_impart->preeditmaxsize_id = XInternAtom(dpy, _XIMP_PREEDITMAXSIZE, False); + im->ximp_impart->im_proto_vl = version; + im->ximp_impart->im_styles = imstyle;; + im->ximp_impart->im_keyslist = keylist; + im->ximp_impart->im_offkeyslist = offkeylist; + im->ximp_impart->type_id = type_id; + im->ximp_impart->type_list = type_list; + im->ximp_impart->im_server_name = server_name; + im->ximp_impart->im_server_vl = server_vl; + im->ximp_impart->im_vendor_name = vendor_name; + im->ximp_impart->im_ext_list = ext_list; + + _Ximp_SetupExtension(im); + _XRegisterFilterByType(im->core.display, fe_window_id, + DestroyNotify, DestroyNotify, + _Ximp_XimFilter_Destroy, NULL); + XSelectInput(im->core.display, fe_window_id, StructureNotifyMask); ! IS_SERVER_CONNECTED(im) = True ; ! return(True); ! } ! Bool ! _Ximp_LocalConnect( im ) ! Ximp_XIM im; ! { ! im->ximp_impart->type_list = NULL; /* dummy */ ! im->ximp_impart->im_server_name = NULL; /* dummy */ ! im->ximp_impart->im_vendor_name = NULL; /* dummy */ ! im->ximp_impart->im_proto_vl = NULL; /* dummy */ ! im->ximp_impart->im_proto_vnum = 0; /* dummy */ ! im->ximp_impart->im_ext_list = 0; /* dummy */ ! im->ximp_impart->im_styles = (XIMStyles *)Xmalloc(sizeof(XIMStyles)); ! if( im->ximp_impart->im_styles ) { ! im->ximp_impart->im_styles->supported_styles = (XIMStyle *)Xmalloc(sizeof(XIMStyle) * 2); ! im->ximp_impart->im_styles->count_styles = 2; ! if( im->ximp_impart->im_styles->supported_styles == NULL ) { ! Xfree( im->ximp_impart->im_styles ); ! im->ximp_impart->im_styles = NULL; ! return( False ); } ! im->ximp_impart->im_styles->supported_styles[0] = XIMPreeditNone | XIMStatusNone; ! im->ximp_impart->im_styles->supported_styles[1] = XIMPreeditNothing | XIMStatusNothing; ! } ! else { ! return( False ); ! } ! im->methods = &Ximp_local_im_methods; ! _Ximp_Local_OpenIM_hook( im ); ! return( True ); } int ! _Ximp_SetupFree(proto_vl, style_list, type_list, keys_list, off_keys_list, server_name, server_vl, vendor_name, ext_list) ! char *proto_vl; ! XIMStyles *style_list; ! long *type_list; ! Ximp_KeyList *keys_list; ! Ximp_KeyList *off_keys_list; ! char *server_name; ! char *server_vl; ! char *vendor_name; ! Atom *ext_list; { ! if(proto_vl) ! Xfree(proto_vl); ! if(style_list) { ! Xfree(style_list->supported_styles); ! Xfree(style_list); ! } ! if(type_list) ! Xfree(type_list); ! if(keys_list) { ! Xfree(keys_list->keys_list); ! Xfree(keys_list); ! } ! if(off_keys_list) { ! Xfree(off_keys_list->keys_list); ! Xfree(off_keys_list); ! } ! if(server_name) ! Xfree(server_name); ! if(server_vl) ! Xfree(server_vl); ! if(vendor_name) ! Xfree(vendor_name); ! if(ext_list) ! Xfree(ext_list); } static Bool _Ximp_GetStyle(im, p_style) ! Ximp_XIM im; ! XIMStyles **p_style; { ! XIMStyles *p; ! int i; ! ! if(!IS_SERVER_CONNECTED(im) && !(IS_DELAYBINDABLE(im))){ ! *p_style = (XIMStyles *)NULL; ! return(False); ! } ! if(IS_SERVER_CONNECTED(im)) p = im->ximp_impart->im_styles; ! else ! p = im->ximp_impart->delaybind_styles; ! ! if((*p_style = (XIMStyles *)Xmalloc(sizeof(XIMStyles) ! + p->count_styles * sizeof(XIMStyle))) == NULL) ! return(False); ! (*p_style)->count_styles = p->count_styles; ! (*p_style)->supported_styles = (XIMStyle *)((char *)*p_style + sizeof(XIMStyles)); ! for(i=0; i < (int)p->count_styles; i++) { ! (*p_style)->supported_styles[i] = p->supported_styles[i]; ! } ! return(True); } ! static char * ! _Ximp_GetIMValues(im, values) ! Ximp_XIM im; ! XIMArg *values; { ! XIMArg *p; ! ! for(p = values; p->name != NULL; p++) { ! if(strcmp(p->name, XNQueryInputStyle) == 0) { ! if( _Ximp_GetStyle(im, p->value) == False) ! break; ! } else { ! if( _Ximp_GetIMExtension(im, p->name, p->value) == False) ! break; ! } ! } ! return(p->name); } *** /tmp/d03454 Tue Mar 9 09:18:15 1993 --- mit/lib/X/Ximp/XimpLCd.c Tue Mar 9 09:18:12 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpLCd.c,v 1.5 92/04/22 11:53:17 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpLCd.c,v 1.7 92/10/19 19:24:53 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 28,55 **** /****************************************************************** ! Copyright 1991, 1992 by FUJITSU LIMITED Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, ! provided that the above copyright notice appear in all copies and ! that both that copyright notice and this permission notice appear ! in supporting documentation, and that the name of FUJITSU LIMITED ! not be used in advertising or publicity pertaining to distribution ! of the software without specific, written prior permission. ! FUJITSU LIMITED makes no representations about the suitability of ! this software for any purpose. It is provided "as is" without ! express or implied warranty. ! FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, ! INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, ! IN NO EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT ! OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS ! OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE ! OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE ! OR PERFORMANCE OF THIS SOFTWARE. ! Author: Takashi Fujiwara FUJITSU LIMITED ******************************************************************/ /* --- 28,58 ---- /****************************************************************** ! Copyright 1991, 1992 by FUJITSU LIMITED. ! Copyright 1991, 1992 by Sun Microsystems, Inc. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, ! provided that the above copyright notice appear in all copies and that ! both that copyright notice and this permission notice appear in ! supporting documentation, and that the name of FUJITSU LIMITED or Sun ! Microsystems, Inc. not be used in advertising or publicity pertaining ! to distribution of the software without specific, written prior ! permission. FUJITSU LIMITED and Sun Microsystems, Inc. make no ! representations about the suitability of this software for any ! purpose. It is provided "as is" without express or implied warranty. ! FUJITSU LIMITED AND SUN MICROSYSTEMS, INC. DISCLAIMS ALL WARRANTIES ! WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND SUN ! MICROSYSTEMS, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR ! CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF ! USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR ! OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ! PERFORMANCE OF THIS SOFTWARE. ! Author: Takashi Fujiwara FUJITSU LIMITED ! Hideki Hiura Sun Microsystems, Inc. ******************************************************************/ /* *************** *** 68,312 **** #include "Xlcint.h" #include "Ximplc.h" ! EncodingRec default_encoding[] = { ! { ISO8859_1, "ISO8859-1", 1, "B", 94, "A", 96 }, ! { ISO8859_2, "ISO8859-2", 1, "B", 94, "B", 96 }, ! { ISO8859_3, "ISO8859-3", 1, "B", 94, "C", 96 }, ! { ISO8859_4, "ISO8859-4", 1, "B", 94, "D", 96 }, ! { ISO8859_7, "ISO8859-7", 1, "B", 94, "F", 96 }, ! { ISO8859_6, "ISO8859-6", 1, "B", 94, "G", 96 }, ! { ISO8859_8, "ISO8859-8", 1, "B", 94, "H", 96 }, ! { ISO8859_5, "ISO8859-5", 1, "B", 94, "L", 96 }, ! { ISO8859_9, "ISO8859-9", 1, "B", 94, "M", 96 }, ! { JISX0201_1976_0, "JISX0201.1976-0", 1, "J", 94, "I", 94 }, ! { GB2312_1980_0, "GB2312.1980-0", 2, "A", 94, "A", 94 }, ! { GB2312_1980_1, "GB2312.1980-1", 2, NULL, 0, "A", 94 }, ! { JISX0208_1983_0, "JISX0208.1983-0", 2, "B", 94, "B", 94 }, ! { JISX0208_1983_1, "JISX0208.1983-1", 2, NULL, 0, "B", 94 }, ! { KSC5601_1987_0, "KSC5601.1987-0", 2, "C", 94, "C", 94 }, ! { KSC5601_1987_1, "KSC5601.1987-1", 2, NULL, 0, "C", 94 } } ; ! EncodingRec **encoding_table = NULL; ! typedef struct { ! char *name; ! XLCdXimpMethods *methods; ! } LCMethodsRec; ! extern XLCdXimpMethods def_lc_methods, euc_lc_methods; ! #ifdef USE_SJIS ! extern XLCdXimpMethods sjis_lc_methods; ! #endif ! static LCMethodsRec default_lc_methods[] = { ! { "C", &def_lc_methods }, ! { "ISO8859-1", &def_lc_methods }, ! { "EUC", &euc_lc_methods }, ! #ifdef USE_SJIS ! { "SJIS", &sjis_lc_methods }, ! #endif ! }; ! static LCMethodsRec **lc_methods_table = NULL; ! static Bool ! init_encoding_table() { ! int table_size; ! EncodingRec **table_ptr, *def_ptr; ! table_size = sizeof(default_encoding) / sizeof(EncodingRec) + 1; ! encoding_table = (EncodingRec **) Xmalloc(sizeof(EncodingRec *) * ! table_size); ! if (encoding_table == NULL) ! return False; ! def_ptr = default_encoding; ! table_ptr = encoding_table; ! while (--table_size) ! *table_ptr++ = def_ptr++; ! *table_ptr = NULL; ! ! return True; } ! static Bool ! set_lc_methods(lcd) ! Ximp_XLCd lcd; { ! char *name = lcd->ximp_lcpart->codeset_name; ! LCMethodsRec **table_ptr, *methods_tbl; ! int table_size; ! if (lc_methods_table == NULL) { ! table_size = sizeof(default_lc_methods) / sizeof(LCMethodsRec) + 1; ! lc_methods_table = (LCMethodsRec **) Xmalloc(sizeof(LCMethodsRec *) * ! table_size); ! if (lc_methods_table == NULL) ! return False; ! ! methods_tbl = default_lc_methods; ! table_ptr = lc_methods_table; ! while (--table_size) ! *table_ptr++ = methods_tbl++; ! *table_ptr = NULL; } ! table_ptr = lc_methods_table; ! while (methods_tbl = *table_ptr++) { ! if (_Ximp_CompareISOLatin1(name, methods_tbl->name) == 0) { ! lcd->ximp_lcpart->methods = methods_tbl->methods; ! return (*methods_tbl->methods->initialize)(lcd); ! } ! } ! ! return False; } ! static XLCd ! _Ximp_init_locale(locale) ! char *locale; { ! Ximp_XLCd lcd; ! if ((lcd = (Ximp_XLCd) Xmalloc(sizeof(Ximp_XLCdRec))) == NULL) ! goto error; ! lcd->core.name = locale; /* not allocation here */ - if ((lcd->ximp_lcpart = - (XLCdXimpRec *) Xmalloc(sizeof(XLCdXimpRec))) == NULL) - goto error; - lcd->ximp_lcpart->codeset = NULL; - - if (encoding_table == NULL) - if (init_encoding_table() == False) - goto error; ! if (_Ximp_load_codeset_data(lcd) == False) ! goto error; ! if (set_lc_methods(lcd) == False) ! goto error; ! return (XLCd) lcd; ! error: ! if (lcd) { ! if (lcd->ximp_lcpart) { ! if (lcd->ximp_lcpart->codeset) ! (void) _Ximp_free_codeset(lcd); ! Xfree(lcd->ximp_lcpart); ! } ! Xfree(lcd); ! } ! return NULL; } - extern XFontSet _Ximp_Create_fontset(); - extern XIM _Ximp_OpenIM(); - - static XLCdMethodsRec lcd_methods = { - _XlcDefaultMapModifiers, - _Ximp_Create_fontset, - _Ximp_OpenIM, - }; - XLCd _XlcDefaultLoader(name) ! char *name; ! { ! XLCd xlcd; #if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE) ! char siname[256]; ! char *_XlcMapOSLocaleName(); ! _XlcMapOSLocaleName(name, siname); ! if(!(xlcd = (XLCd) _Ximp_init_locale(siname))) ! return((XLCd)NULL); ! #else ! if(!(xlcd = (XLCd) _Ximp_init_locale(name))) ! return((XLCd)NULL); #endif ! xlcd->methods = &lcd_methods; ! xlcd->core.name = Xmalloc(strlen(name) + 1); ! if(!xlcd->core.name) { ! Xfree(xlcd); ! return((XLCd)NULL); ! } ! strcpy(xlcd->core.name, name); ! xlcd->core.modifiers = NULL; ! return(xlcd); ! } static void ! _Ximp_mbinit(state) XPointer state; { ! Ximp_XLCd lcd = (Ximp_XLCd) state; ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); } static char ! _Ximp_mbchar(state, str, lenp) XPointer state; char *str; int *lenp; { ! Ximp_XLCd lcd = (Ximp_XLCd) state; ! return (*lcd->ximp_lcpart->methods->mbchar)(lcd, str, lenp); } static void ! _Ximp_mbfinish(state) XPointer state; { ! Ximp_XLCd lcd = (Ximp_XLCd) state; ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); } static char * ! _Ximp_lcname(state) XPointer state; { ! Ximp_XLCd lcd = (Ximp_XLCd) state; ! ! return lcd->core.name; } static void ! _Ximp_destroy(state) XPointer state; { } ! static XrmMethodsRec Ximp_mb_methods = { ! _Ximp_mbinit, ! _Ximp_mbchar, ! _Ximp_mbfinish, ! _Ximp_lcname, ! _Ximp_destroy } ; XrmMethods ! _XrmInitParseInfo(state) ! XPointer *state; { ! Ximp_XLCd lcd; ! if ((lcd = (Ximp_XLCd) _XlcCurrentLC()) == NULL) return NULL; ! *state = (XPointer) lcd; ! return &Ximp_mb_methods; } --- 71,385 ---- #include "Xlcint.h" #include "Ximplc.h" ! static CharSetRec default_charset[] = { ! { "ISO8859-1", GL, 1, "\033(B", 94, True }, ! { "ISO8859-1", GR, 1, "\033-A", 96, False }, ! { "ISO8859-2", GR, 1, "\033-B", 96, False }, ! { "ISO8859-3", GR, 1, "\033-C", 96, False }, ! { "ISO8859-4", GR, 1, "\033-D", 96, False }, ! { "ISO8859-7", GR, 1, "\033-F", 96, False }, ! { "ISO8859-6", GR, 1, "\033-G", 96, False }, ! { "ISO8859-8", GR, 1, "\033-H", 96, False }, ! { "ISO8859-5", GR, 1, "\033-L", 96, False }, ! { "ISO8859-9", GR, 1, "\033-M", 96, False }, ! { "JISX0201.1976-0", GL, 1, "\033(J", 94, True }, ! { "JISX0201.1976-0", GR, 1, "\033)I", 94, False }, ! { "GB2312.1980-0", GL, 2, "\033$(A", 94, False }, ! { "GB2312.1980-0", GR, 2, "\033$)A", 94, False }, ! { "JISX0208.1983-0", GL, 2, "\033$(B", 94, False }, ! { "JISX0208.1983-0", GR, 2, "\033$)B", 94, False }, ! { "KSC5601.1987-0", GL, 2, "\033$(C", 94, False }, ! { "KSC5601.1987-0", GR, 2, "\033$)C", 94, False }, ! ! /* Non-Standard Character Set Encodings */ ! { "CNS11643-0", GL, 1, "\033(D", 94, True }, ! { "CNS11643-0", GR, 1, "\033)D", 94, False }, ! { "CNS11643-1", GR, 2, "\033$)G", 94, False }, ! { "CNS11643-2", GR, 2, "\033$)H", 94, False }, ! { "CNS11643-14", GR, 2, "\033$)I", 94, False }, ! { "CNS11643-15", GR, 2, "\033$)J", 94, False }, ! { "CNS11643-16", GR, 2, "\033$)K", 94, False }, } ; ! static CharSet *charset_list = NULL; ! #ifdef DYNAMICLIB ! static XLCdMethodsRec lcd_methods ; ! #endif ! Bool ! _XlcRegisterCharSet(charset) ! CharSet charset; ! { ! CharSet *new; ! static num; ! if (charset_list == NULL) { ! charset_list = (CharSet *) Xmalloc (2 * sizeof(CharSet)); ! if (charset_list == NULL) ! return False; ! charset_list[0] = charset; ! charset_list[1] = (CharSet) NULL; ! num = 1; ! } else { ! new = (CharSet *) Xrealloc(charset_list, sizeof(CharSet) * (num + 2)); ! if (new == NULL) ! return False; ! charset_list = new; ! charset_list[num] = charset; ! charset_list[num + 1] = (CharSet) NULL; ! num++; ! } + return True; + } ! CharSet ! _XlcGetCharSetFromEncoding(encoding) ! char *encoding; { ! CharSet *charset = charset_list; ! for ( ; *charset; charset++) { ! if (!strcmp((*charset)->encoding, encoding)) ! return *charset; ! } ! return (CharSet) NULL; } ! CharSet ! _XlcGetCharSetFromName(name, side) ! char *name; ! unsigned side; { ! CharSet *charset = charset_list; ! for ( ; *charset; charset++) { ! if (!strcmp((*charset)->name, name) && (*charset)->side == side) ! return *charset; } ! return (CharSet) NULL; } ! CodeSet ! _XlcGetCodeSetFromCharSet(lcd, charset) ! XimpLCd lcd; ! CharSet charset; { ! CodeSet *codeset = lcd->locale.codeset_list; ! CharSet *charset_list; ! int charset_num, codeset_num = lcd->locale.codeset_num; ! for ( ; codeset_num-- > 0; codeset++) { ! charset_list = (*codeset)->charset_list; ! charset_num = (*codeset)->charset_num; ! for ( ; charset_num-- > 0; charset_list++) ! if (*charset_list == charset) ! return *codeset; ! } ! return (CodeSet) NULL; ! } ! extern XLCd _XlcCLoader(), _XlcGenericLoader(); ! #ifdef XIMP_BC ! extern XLCd _XlcEUCLoader(); ! #endif ! #ifdef USE_SJIS ! extern XLCd _XlcSJISLoader(); ! #endif ! static XLCdLoadProc default_loader[] = { ! _XlcCLoader, ! #ifdef XIMP_BC ! _XlcEUCLoader, ! #endif ! #ifdef USE_SJIS ! _XlcSJISLoader, ! #endif ! _XlcGenericLoader, ! }; ! static XLCdLoadProc *loader_list = NULL; ! Bool ! _XlcInsertLoader(proc) ! XLCdLoadProc proc; ! { ! XLCdLoadProc *new; ! static num; ! if (loader_list == NULL) { ! loader_list = (XLCdLoadProc *) Xmalloc (2 * sizeof(XLCdLoadProc)); ! if (loader_list == NULL) ! return False; ! ! loader_list[0] = proc; ! loader_list[1] = (XLCdLoadProc) NULL; ! num = 1; ! } else { ! new = (XLCdLoadProc *) Xrealloc(loader_list, sizeof(XLCdLoadProc) ! * (num + 2)); ! if (new == NULL) ! return False; ! ! loader_list = new; ! loader_list[num] = proc; ! loader_list[num + 1] = (XLCdLoadProc) NULL; ! num++; ! } ! return True; } XLCd + #ifndef DYNAMICLIB _XlcDefaultLoader(name) ! #else ! _XlcInitLocale(name) ! #endif ! char *name; ! { ! XLCd lcd; ! CharSet charset; ! XLCdLoadProc *proc; ! int num; #if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE) ! char siname[256]; ! char *_XlcMapOSLocaleName(); ! name = _XlcMapOSLocaleName(name, siname); #endif ! if (charset_list == NULL) { ! num = sizeof(default_charset) / sizeof(CharSetRec); ! for (charset = default_charset; num-- > 0; charset++) ! if (_XlcRegisterCharSet(charset) == False) ! return (XLCd) NULL; ! } + if (loader_list == NULL) { + num = sizeof(default_loader) / sizeof(XLCdLoadProc); + for (proc = default_loader; num-- > 0; proc++) + if (_XlcInsertLoader(*proc) == False) + return (XLCd) NULL; + } + + for (proc = loader_list; *proc; proc++) + if (lcd = (*proc)(name)) + break; + #ifdef DYNAMICLIB + lcd->methods = &lcd_methods ; + #endif + return lcd; + } + + + static void ! mbinit(state) XPointer state; { ! LCMethods methods = LC_METHODS(((State)state)->lcd); ! (*methods->cnv_start)(state); } static char ! mbchar(state, str, lenp) XPointer state; char *str; int *lenp; { ! LCMethods methods = LC_METHODS(((State)state)->lcd); ! return (*methods->mbchar)(state, str, lenp); } static void ! mbfinish(state) XPointer state; { ! LCMethods methods = LC_METHODS(((State)state)->lcd); ! (*methods->cnv_end)(state); } static char * ! lcname(state) XPointer state; { ! return ((State)state)->lcd->core.name; } static void ! destroy(state) XPointer state; { + LCMethods methods = LC_METHODS(((State)state)->lcd); + + (*methods->destroy_state)(state); } ! static XrmMethodsRec rm_methods = { ! mbinit, ! mbchar, ! mbfinish, ! lcname, ! destroy } ; XrmMethods ! #ifndef DYNAMICLIB ! _XrmInitParseInfo(statep) ! XPointer *statep; ! #else ! _XimprmInitParseInfo(lcd, state) ! State *state; ! XLCd lcd ; ! #endif { ! #ifndef DYNAMICLIB ! State *state = (State *)statep; ! XLCd lcd = _XlcCurrentLC(); ! #endif ! LCMethods methods; ! if (lcd == NULL) return NULL; ! methods = LC_METHODS(lcd); ! *state = (methods->create_state)(lcd); ! if (*state == NULL) ! return NULL; ! return &rm_methods; } + + #ifdef DYNAMICLIB + extern int _XimpmbTextPropertyToTextList(); + extern int _XimpwcTextPropertyToTextList(); + extern int _XimpmbTextListToTextProperty(); + extern int _XimpwcTextListToTextProperty(); + extern XrmMethods _XimprmInitParseInfo(); + extern void _XimpwcFreeStringList(); + extern char *_XimpDefaultString(); + + static XLCdMethodsRec lcd_methods = { + _XlcDefaultMapModifiers, + _XDefaultCreateFontSet, + _Ximp_OpenIM, + _XimprmInitParseInfo, + _XimpmbTextPropertyToTextList, + _XimpwcTextPropertyToTextList, + _XimpmbTextListToTextProperty, + _XimpwcTextListToTextProperty, + _XimpwcFreeStringList, + _XimpDefaultString + }; + #endif *** /tmp/d03476 Tue Mar 9 09:18:27 1993 --- mit/lib/X/Ximp/XimpLkup.c Tue Mar 9 09:18:24 1993 *************** *** 1,40 **** ! /* $XConsortium: XimpLkup.c,v 1.8 92/07/29 10:16:17 rws Exp $ */ /****************************************************************** ! ! Copyright 1991, 1992 by Sony Corporation ! Copyright 1991, 1992 by FUJITSU LIMITED ! Copyright 1991, 1992 by Fuji Xerox Co.,Ltd. ! Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Sony Corporation, ! FUJITSU LIMITED and Fuji Xerox Co.,Ltd. not be used in advertising ! or publicity pertaining to distribution of the software without ! specific, written prior permission. Sony Corporation, FUJITSU LIMITED and Fuji Xerox Co.,Ltd. make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. ! ! SONY CORPORATION, FUJITSU LIMITED AND FUJI XEROX CO.,LTD. DISCLAIM ! ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED ! WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SONY CORPORATION, FUJITSU LIMITED, FUJI XEROX CO.,LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ! Author: Masaki Takeuchi Sony Corporation Takashi Fujiwara FUJITSU LIMITED Kazunori Nishihara Fuji Xerox Co.,Ltd. Makoto Wakamatsu Sony Corporation ! ******************************************************************/ #define NEED_EVENTS - #include #include "Xlibint.h" #include "Xutil.h" #include "Xlcint.h" --- 1,41 ---- ! /* $XConsortium: XimpLkup.c,v 1.9 92/10/19 19:24:57 rws Exp $ */ /****************************************************************** ! ! Copyright 1991, 1992 by Sony Corporation ! Copyright 1991, 1992 by FUJITSU LIMITED ! Copyright 1991, 1992 by Fuji Xerox Co.,Ltd. ! Copyright 1991, 1992 by Sun Microsystems, Inc. ! Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Sony Corporation, ! FUJITSU LIMITED, Fuji Xerox Co.,Ltd. and Sun Microsystems, Inc. not ! be used in advertising or publicity pertaining to distribution of the ! software without specific, written prior permission. Sony Corporation, FUJITSU LIMITED and Fuji Xerox Co.,Ltd. make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. ! ! SONY CORPORATION, FUJITSU LIMITED FUJI XEROX CO.,LTD. AND SUN MICROSYSTEMS, ! INC. DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL ! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SONY CORPORATION, FUJITSU LIMITED, FUJI XEROX CO.,LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ! Author: Masaki Takeuchi Sony Corporation Takashi Fujiwara FUJITSU LIMITED Kazunori Nishihara Fuji Xerox Co.,Ltd. + Hideki Hiura Sun Microsystems, Inc. Makoto Wakamatsu Sony Corporation ! ******************************************************************/ #define NEED_EVENTS #include "Xlibint.h" #include "Xutil.h" #include "Xlcint.h" *************** *** 47,54 **** extern Atom _Ximp_Protocol_id(); extern Bool _Ximp_XimFilter_Client(); extern Bool _Ximp_XimFilter_Destroy(); ! static Bool _Ximp_StartXIMP(); ! extern Bool _Ximp_SetOpenXIMP(); extern void _Ximp_IM_SendMessage(); extern int _Ximp_SetupFree(); --- 48,54 ---- extern Atom _Ximp_Protocol_id(); extern Bool _Ximp_XimFilter_Client(); extern Bool _Ximp_XimFilter_Destroy(); ! extern Bool _Ximp_ConnectIC(); extern void _Ximp_IM_SendMessage(); extern int _Ximp_SetupFree(); *************** *** 56,64 **** extern void _Ximp_SetupFreeExtension(); extern void _Ximp_ProcExtension(); - static void _Ximp_CallCallback(); extern void _Ximp_ProcError(); Bool _XimpIfEvent( ic, event, predicate, arg ) Ximp_XIC ic; --- 56,65 ---- extern void _Ximp_SetupFreeExtension(); extern void _Ximp_ProcExtension(); extern void _Ximp_ProcError(); + static void _Ximp_ServerProcessStopped(); + Bool _XimpIfEvent( ic, event, predicate, arg ) Ximp_XIC ic; *************** *** 76,84 **** if( event->type == DestroyNotify ) { XPutBackEvent( ic->core.im->core.display, event ); return( False ); } ! else if( event->type == ClientMessage && event->xclient.format == 32 && ! event->xclient.data.l[0] == XIMP_ERROR ) { _Ximp_ProcError( ic, ic->core.im->core.display, NULL, event ); return( False ); } --- 77,110 ---- if( event->type == DestroyNotify ) { XPutBackEvent( ic->core.im->core.display, event ); return( False ); + } else if(ISXIMP_ERROR(event)) { + _Ximp_ProcError( ic, ic->core.im->core.display, NULL, event ); + return( False ); } ! return( True ); ! } ! ! static Bool ! _XimpCheckIfEvent( ic, event, predicate, arg ) ! Ximp_XIC ic; ! XEvent *event; ! Bool (*predicate)( ! #if NeedNestedPrototypes ! Display*, ! XEvent*, ! char* ! #endif ! ); ! char *arg; ! { ! if( !XCheckIfEvent( ic->core.im->core.display, event, predicate, arg ) ) { ! event->type = LASTEvent; ! return( False ); ! } ! if( event->type == DestroyNotify ) { ! XPutBackEvent( ic->core.im->core.display, event ); ! return( False ); ! } else if(ISXIMP_ERROR(event)) { _Ximp_ProcError( ic, ic->core.im->core.display, NULL, event ); return( False ); } *************** *** 85,106 **** return( True ); } - Bool ! _Ximp_CMPredicate(d, ev, arg0) Display *d; XEvent *ev; XPointer arg0; { XimpCMPredicateArg arg = (XimpCMPredicateArg)arg0; ! if( ev->type == ClientMessage ) { ! if( ev->xclient.message_type == arg->type && ! ev->xclient.format == 32 ) { ! if( arg->icid == 0 || (ev->xclient.data.l[1] == arg->icid) ) ! if( ev->xclient.data.l[0] == arg->protocol || ! ev->xclient.data.l[0] == XIMP_ERROR ) return(True); } } else if( ev->type == DestroyNotify) { if( ev->xdestroywindow.window == arg->owner ) { --- 111,137 ---- return( True ); } Bool ! _Ximp_CMPredicateAll(d, ev, arg0) Display *d; XEvent *ev; XPointer arg0; { XimpCMPredicateArg arg = (XimpCMPredicateArg)arg0; + ICID icid; + long nicid; ! if(ev->type == ClientMessage ) { ! if(ev->xclient.message_type == arg->type) { ! if(ev->xclient.format == 32) { ! if(arg->icid == 0 || ISCMOf(ev,1,arg->icid)) return(True); + } else { + nicid = *(unsigned long *)(&(ev->xclient.data.b[0])); + icid = (ICID)ntohl(nicid); + if (icid == arg->icid) + return(True); + } } } else if( ev->type == DestroyNotify) { if( ev->xdestroywindow.window == arg->owner ) { *************** *** 110,918 **** return( False ); } static unsigned char * ! _Ximp_Reset(ic) ! Ximp_XIC ic; { ! XEvent Message; ! XEvent event; XimpCMPredicateArgRec Arg; int rval; Atom actual_type_return; int actual_format_return; ! unsigned long nitems_return, bytes_after_return; unsigned char *p = NULL; ! if(ic->ximp_icpart->icid) { ! /* ClientMessage Send */ ! _Ximp_IM_SendMessage(ic, XIMP_RESET, NULL, NULL, NULL); Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; ! Arg.protocol = XIMP_RESET_RETURN; Arg.icid = ic->ximp_icpart->icid; ! if( !_XimpIfEvent( ic, &event, _Ximp_CMPredicate, (XPointer)&Arg ) ) return( NULL ); ! ic->ximp_icpart->icid =(ICID)event.xclient.data.l[1]; ! rval = XGetWindowProperty( ic->core.im->core.display, ! ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window, ! (Atom)event.xclient.data.l[2], 0, 1024, True, ! AnyPropertyType, &actual_type_return, ! &actual_format_return, &nitems_return, ! &bytes_after_return, &p ); ! return( p ); } ! return( (unsigned char *)NULL ); } - #define XIMP_MAXBUF 1024 - char * ! _Ximp_MbReset(ic) ! Ximp_XIC ic; { ! char *mb; ! int length = XIMP_MAXBUF +1; ! unsigned char *ct = _Ximp_Reset(ic); ! if (!ct) return(NULL); ! mb = Xmalloc(length+1); ! _Ximp_cttombs(ic->core.im->core.lcd, ct, strlen((char *)ct), mb, &length, NULL); ! mb[length] = '\0'; ! return(mb); } wchar_t * ! _Ximp_WcReset(ic) ! Ximp_XIC ic; { ! wchar_t *wc; ! int length = XIMP_MAXBUF +1; ! unsigned char *ct = _Ximp_Reset(ic); ! if (!ct) return(NULL); ! wc = (wchar_t *)Xmalloc((length + 1) * sizeof(wchar_t)); ! _Ximp_cttowcs(ic->core.im->core.lcd, ct, strlen((char *)ct), wc, &length, NULL); ! wc[length] = (wchar_t)0; ! return(wc); } #define LookupKeypress 1 #define LookupProperty 2 #define LookupMessage 3 ! static int _xim_lookup_sign; ! static unsigned char *_xim_prop_return = (unsigned char *) NULL; ! static unsigned long _xim_string_length; ! static int _xim_message_len; ! static unsigned char _xim_message_buf[24]; int _Ximp_MbLookupString(ic, ev, buffer, bytes, keysym, status) ! Ximp_XIC ic; ! XKeyEvent *ev; ! char *buffer; ! int bytes; ! KeySym *keysym; ! Status *status; { ! XComposeStatus comp_status; ! int ret = 0, len; ! Ximp_XLCd lcd; ! unsigned char *s; ! int str_len; ! if(ev->type == KeyPress && ev->keycode == 0) { /* Filter function */ ! if ((_xim_lookup_sign == LookupProperty) || ! (_xim_lookup_sign == LookupMessage)) { ! if (_xim_lookup_sign == LookupMessage) { ! s = _xim_message_buf; ! str_len = _xim_message_len; ! } else { ! s = _xim_prop_return; ! str_len = _xim_string_length; ! } ! lcd = (Ximp_XLCd)ic->core.im->core.lcd; ! len = _Ximp_ct_mbslen(lcd, s, str_len, NULL); ! if (len > bytes) { ! ret = len; ! if(status) *status = XBufferOverflow; ! } else if (_Ximp_cttombs(lcd, s, str_len, ! buffer, &bytes, NULL) <= 0) { ! ret = 0; ! if(status) *status = XLookupNone; ! } else { ! ret = bytes; ! if(status) *status = XLookupChars; ! } ! return(ret); ! } else { ! if(status) *status = XLookupNone; ! return(0); ! } } ! else if(ev->type == KeyPress) { ! if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { ! if(status) *status = XLookupNone; ! return(0); ! } ! ic->ximp_icpart->putback_key_event = False; ! ret = _Ximp_LookupMBText(ic, ev, buffer, bytes, keysym, &comp_status); ! if(ret > 0) { ! if(keysym && *keysym != NoSymbol) { ! if(status) *status = XLookupBoth; ! } ! else { ! if(status) *status = XLookupChars; ! } ! } ! else { ! if(keysym && *keysym != NoSymbol) { ! if(status) *status = XLookupKeySym; ! } ! else { ! if(status) *status = XLookupNone; ! } ! } ! } ! else { ! if (status) *status = XLookupNone; ! } ! return(ret); } int _Ximp_WcLookupString(ic, ev, buffer, wlen, keysym, status) ! Ximp_XIC ic; ! XKeyEvent *ev; ! wchar_t *buffer; ! int wlen; ! KeySym *keysym; ! Status *status; { ! XComposeStatus comp_status; ! int ret, len; ! char look[128]; ! Ximp_XLCd lcd; ! unsigned char *s; ! int str_len; ! if(ev->type == KeyPress && ev->keycode == 0) { /* Filter function */ ! if ((_xim_lookup_sign == LookupProperty) || ! (_xim_lookup_sign == LookupMessage)) { ! if (_xim_lookup_sign == LookupMessage) { ! s = _xim_message_buf; ! str_len = _xim_message_len; ! } else { ! s = _xim_prop_return; ! str_len = _xim_string_length; ! } ! lcd = (Ximp_XLCd)ic->core.im->core.lcd; ! len = _Ximp_ct_wcslen(lcd, s, str_len, NULL); ! if (len > wlen) { ! ret = len; ! if(status) *status = XBufferOverflow; ! } else if (_Ximp_cttowcs(lcd, s, str_len, ! buffer, &wlen, NULL) <= 0) { ! ret = 0; ! if(status) *status = XLookupNone; ! } else { ! ret = wlen; ! if(status) *status = XLookupChars; ! } ! return(ret); ! } else { ! if(status) *status = XLookupNone; ! return(0); ! } } ! else if(ev->type == KeyPress) { ! if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { ! if(status) *status = XLookupNone; ! return(0); ! } ! ic->ximp_icpart->putback_key_event = False; ! ret = _Ximp_LookupWCText(ic, ev, buffer, wlen, keysym, &comp_status); ! if(ret > 0) { ! if(keysym && *keysym != NoSymbol) { ! if(status) *status = XLookupBoth; ! } ! else { ! if(status) *status = XLookupChars; ! } ! } ! else { ! if(keysym && *keysym != NoSymbol) { ! if(status) *status = XLookupKeySym; ! } ! else { ! if(status) *status = XLookupNone; ! } ! } ! } ! else { ! if (status) *status = XLookupNone; ! } ! return(ret); } static Bool _Ximp_FocusInput (window, mask) ! Window window; ! unsigned long *mask; { ! int i; ! Ximp_XIM pim; ! Ximp_XIC pic; ! extern int Ximp_Xim_count; ! extern Ximp_XIM *Ximp_Xim_List; ! for(i = 0; i < Ximp_Xim_count; i++) { ! if( (pim = Ximp_Xim_List[i]) == NULL ) ! continue; ! for (pic = (Ximp_XIC)pim->core.ic_chain; ! pic; pic = (Ximp_XIC)pic->core.next) { ! if(pic->core.focus_window == window && ! pic->ximp_icpart->input_mode) { ! *mask = pic->ximp_icpart->back_mask; ! return(True); ! } ! } } ! return (False); } static Bool ! _Ximp_StartXIMP(ic, ev, keysym) ! Ximp_XIC ic; ! XKeyEvent *ev; ! KeySym keysym; { ! Ximp_KeyList *list; ! int i, isEventPassedToIMS; ! XWindowAttributes ret_attributes; ! unsigned long dummy_mask; ! XEvent Message; ! extern Bool _Ximp_Setup (); ! if (ic->ximp_icpart->input_mode) { /* ON : input_mode */ ! if (!ic->ximp_icpart->putback_key_event && ev->keycode != 0) { ! _Ximp_IM_SendMessage( ic, XIMP_KEYPRESS, ! (long)ev->keycode, ! (long)ev->state, NULL ); ! return (True); ! } ! return (False); } ! if(!(((Ximp_XIM)ic->core.im)->ximp_impart->connectserver)) { ! if( (list = ((Ximp_XIM)ic->core.im)->ximp_impart->process_start_keys) == NULL ) ! return(False); ! for(i = 0, isEventPassedToIMS = 1; i < (int)list->count_keys; i++) { ! if( (keysym && keysym == list->keys_list[i].keysym) ! && ((ev->state & list->keys_list[i].modifier_mask) ! == list->keys_list[i].modifier ) ) { ! isEventPassedToIMS = (_Ximp_Setup( ic->core.im ) == False); ! break; ! } ! } ! } ! else { ! list = ((Ximp_XIM)ic->core.im)->ximp_impart->im_keyslist; ! for(i = 0, isEventPassedToIMS = 1; i < (int)list->count_keys; i++) { ! if( (keysym && keysym == list->keys_list[i].keysym) ! && ((ev->state & list->keys_list[i].modifier_mask) ! == list->keys_list[i].modifier ) ) { ! isEventPassedToIMS = 0; ! break; ! } ! } ! } ! if(isEventPassedToIMS) return(False); ! if(ic->ximp_icpart->icid == NULL) ! if(!(_Ximp_SetOpenXIMP(ic, XIMP_START_IC))) return(False); ! if (_Ximp_FocusInput (ic->core.focus_window, &dummy_mask)) ! ic->ximp_icpart->back_mask = dummy_mask; ! else { ! Display *d = ic->core.im->core.display; ! XGetWindowAttributes(d, ic->core.focus_window, &ret_attributes); ! dummy_mask = ret_attributes.your_event_mask; ! ic->ximp_icpart->back_mask = dummy_mask; ! if(ic->ximp_icpart->is_bep_mode == XIMP_FRONTEND) ! dummy_mask &= ~(KeyPressMask | KeyReleaseMask); ! else ! dummy_mask &= ~(KeyReleaseMask); ! XSelectInput(d, ic->core.focus_window, dummy_mask); } ! ic->ximp_icpart->input_mode = 1; ! _Ximp_IM_SendMessage(ic, XIMP_MOVE, ! ic->ximp_icpart->preedit_attr.SpotLocation.x, ! ic->ximp_icpart->preedit_attr.SpotLocation.y, ! NULL); ! _Ximp_IM_SendMessage(ic, XIMP_BEGIN, NULL, NULL, NULL); ! XFlush(ic->core.im->core.display); ! _Ximp_CallRestartCallbackExtension( ic ); ! return(True); } ! Bool ! _Ximp_SetOpenXIMP(ic, mode) ! Ximp_XIC ic; ! int mode; { - unsigned long mask; - XEvent event; XimpCMPredicateArgRec Arg; if(mode == XIMP_CREATE_IC) { /* XCretaeIC() */ if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { ! ic->core.client_window = XCreateSimpleWindow( ! ic->core.im->core.display, ! DefaultRootWindow(ic->core.im->core.display), ! 0, 0, 1, 1, 1, 0, 0); } } ! if(!(ic->ximp_icpart->proto_mask & XIMP_FOCUS_WIN_MASK)) { ic->core.focus_window = ic->core.client_window; } ! /* Property Data Set */ ! XChangeProperty(ic->core.im->core.display, ic->core.client_window, ((Ximp_XIM)ic->core.im)->ximp_impart->version_id, XA_STRING, 8, PropModeReplace, (unsigned char *)XIMP_PROTOCOL_VERSION, strlen(XIMP_PROTOCOL_VERSION)); ! XFlush(ic->core.im->core.display); ! mask = ic->ximp_icpart->proto_mask; ! _Ximp_SetFocusWindow(ic); ! mask |= XIMP_FOCUS_WIN_MASK; if(!( (ic->core.input_style & XIMPreeditCallbacks) || (ic->core.input_style & XIMPreeditNone) ) ) { ! if(mask & XIMP_PROP_PREEDIT) ! _Ximp_SetPreeditAtr(ic); ! if(mask & XIMP_PROP_PREFONT) ! _Ximp_SetPreeditFont(ic); } - else { - mask &= ~(XIMP_PROP_PREEDIT | XIMP_PROP_PREFONT); - } if(!( (ic->core.input_style & XIMStatusCallbacks) || (ic->core.input_style & XIMStatusNone) ) ) { ! if(mask & XIMP_PROP_STATUS) _Ximp_SetStatusAtr(ic); ! if(mask & XIMP_PROP_STSFONT) _Ximp_SetStatusFont(ic); } ! else { ! mask &= ~(XIMP_PROP_STATUS | XIMP_PROP_STSFONT); ! } ! ! /* ClientMessage Send */ ! _Ximp_IM_SendMessage(ic, XIMP_CREATE, ic->core.input_style, mask, NULL); ! Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; ! Arg.protocol = XIMP_CREATE_RETURN; Arg.icid = 0; ! if( _XimpIfEvent( ic, &event, _Ximp_CMPredicate, (XPointer)&Arg ) ) { ic->ximp_icpart->icid = (ICID)event.xclient.data.l[1]; ! _Ximp_A_CreateExtension(ic); ! return(True); ! } ! else { ! XDeleteProperty( ic->core.im->core.display, ! ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->focus_win_id ); ! if( !((ic->core.input_style & XIMPreeditCallbacks) || ! (ic->core.input_style & XIMPreeditNone)) ) { ! if( mask & XIMP_PROP_PREEDIT ) ! XDeleteProperty( ic->core.im->core.display, ! ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id ); ! if( mask & XIMP_PROP_PREFONT ) ! XDeleteProperty( ic->core.im->core.display, ! ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->preeditfont_id ); } - if( !((ic->core.input_style & XIMStatusCallbacks) || - (ic->core.input_style & XIMStatusNone)) ) { - if( mask & XIMP_PROP_STATUS ) - XDeleteProperty( ic->core.im->core.display, - ic->core.client_window, - ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id ); - if( mask & XIMP_PROP_STSFONT ) - XDeleteProperty( ic->core.im->core.display, - ic->core.client_window, - ((Ximp_XIM)ic->core.im)->ximp_impart->statusfont_id ); - } - return( False ); } } void _Ximp_MakeKeypress (d, w, ev) ! Display *d; ! Window w; ! XKeyEvent *ev; { ! ev->type = KeyPress; ! ev->keycode = 0; } ! Bool ! _Ximp_ProcKeypress (d, w, ev, kev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; ! XKeyEvent *kev; { ! ICID icid; ! Ximp_XIC ic; ! icid = ev->data.l[1]; ! if( (ic = _Ximp_LookupXIC(icid)) == NULL ) ! return( False ); ! kev->type = KeyPress; ! kev->serial = ev->serial; ! kev->send_event = False; ! kev->display = ev->display; ! kev->window = ev->window; ! kev->root = DefaultRootWindow(ev->display); ! kev->subwindow = (Window)NULL; ! kev->time = 0L; ! kev->x = 0; ! kev->y = 0; ! kev->x_root = 0; ! kev->y_root = 0; ! kev->keycode = ev->data.l[2]; ! kev->state = ev->data.l[3]; ! kev->same_screen = True; ! if(ic->ximp_icpart->input_mode) { /* ON : input_mode */ ! ic->ximp_icpart->putback_key_event = True; ! } ! return( True ); } static void _Ximp_ProcCreateReturn (d, w, ev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid; ! icid = ev->data.l[1]; } static void ! _Ximp_ProcConversionBegin (d, w, ev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid; ! Ximp_XIC ic; ! XWindowAttributes ret_attributes; ! unsigned long dummy_mask; ! icid = ev->data.l[1]; ! if( (ic = _Ximp_LookupXIC(icid)) == NULL ) ! return; ! if(ic->ximp_icpart->input_mode) /* ON : input_mode */ ! return; ! ! if (_Ximp_FocusInput (ic->core.focus_window, &dummy_mask)) ! ic->ximp_icpart->back_mask = dummy_mask; ! else { ! XGetWindowAttributes(d, ic->core.focus_window, &ret_attributes); ! dummy_mask = ret_attributes.your_event_mask; ! ic->ximp_icpart->back_mask = dummy_mask; ! if(ic->ximp_icpart->is_bep_mode == XIMP_FRONTEND) ! dummy_mask &= ~(KeyPressMask | KeyReleaseMask); ! else ! dummy_mask &= ~(KeyReleaseMask); ! XSelectInput(d, ic->core.focus_window, dummy_mask); ! XFlush(d); } ! ic->ximp_icpart->input_mode = 1; ! return; } ! static void ! _Ximp_ProcConversionEnd (d, w, ev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid; ! Ximp_XIC ic; ! icid = ev->data.l[1]; ! if( (ic = _Ximp_LookupXIC(icid)) == NULL ) ! return; ! XSelectInput(d, ic->core.focus_window, ic->ximp_icpart->back_mask ); ! XFlush(d); ! ic->ximp_icpart->input_mode = 0; return; } static void ! _Ximp_ProcReadProperty (d, w, ev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! Ximp_XIC ic; ! ICID icid; ! Atom read_prop; ! int rval; ! Atom actual_type_return; ! int actual_format_return; ! unsigned long nitems_return; ! if (_xim_prop_return) { ! XFree((XPointer)(_xim_prop_return)); ! } ! icid = ev->data.l[1]; ! read_prop = ev->data.l[2]; ! if( (ic = _Ximp_LookupXIC(icid)) == NULL ) ! return; ! rval = XGetWindowProperty( d, ! ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window, ! read_prop, 0, 1024, True, ! AnyPropertyType, &actual_type_return, ! &actual_format_return, &_xim_string_length, ! &nitems_return, &_xim_prop_return ); ! /* ! * Note: ! * After getting the result from _xim_prop_return, ! * do not forget to do XFree it. ! */ ! _xim_lookup_sign = LookupProperty; } void ! _Ximp_ProcError (ic0, d, w, ev) ! Ximp_XIC ic0; ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid; ! Ximp_XIC ic; ! unsigned long data[3]; ! ! /* ! * ToDo: ! * If you want to process the error from IM server, ! * you should modify this routine. ! */ ! ! if( (icid = ev->data.l[1]) != 0 ) { ! if( (ic = _Ximp_LookupXIC(icid)) == NULL ) ! return; ! } ! else if( (ic = ic0) == NULL ) ! return; ! ! if (ic->ximp_icpart->error.callback) { ! data[0] = ev->data.l[2]; ! data[2] = ev->data.l[4]; ! if(ev->data.l[0] != XIMP_ERROR) ! data[1] = XIMP_BadProtocol; ! else ! data[1] = ev->data.l[3]; ! ! (*ic->ximp_icpart->error.callback)(ic, ! ic->ximp_icpart->error.client_data, ! data); ! } } static void ! _Ximp_ProcReadMessage (d, w, ev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid; ! long nicid; ! nicid = *(unsigned long *)(&(ev->data.b[0])); ! icid = (ICID)ntohl(nicid); ! _xim_message_len = ev->data.b[4]; ! strncpy ((char *)_xim_message_buf, &(ev->data.b[5]), _xim_message_len); ! _xim_message_buf[_xim_message_len] = 0; ! _xim_message_buf[_xim_message_len + 1] = 0; ! _xim_message_buf[_xim_message_len + 2] = 0; ! _xim_message_buf[_xim_message_len + 3] = 0; ! _xim_lookup_sign = LookupMessage; } ! static void ! _Ximp_CallCallback (d, w, ev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid; ! Ximp_XIC ic; ! icid = ev->data.l[1]; ! if( (ic = _Ximp_LookupXIC(icid)) == NULL ) return; ! switch (ev->data.l[0]) { ! case XIMP_GEOMETRY: ! _Ximp_CallGeometryCallback (ic, ev); ! break; ! case XIMP_PREEDITSTART: ! _Ximp_CallPreeditStartCallback (ic, ev); ! break; ! case XIMP_PREEDITDONE: ! _Ximp_CallPreeditDoneCallback (ic, ev); ! break; ! case XIMP_PREEDITDRAW: ! _Ximp_CallPreeditDrawCallback (ic, ev); ! break; ! case XIMP_PREEDITDRAW_CM: ! _Ximp_CallPreeditDrawCallback2 (ic, ev); ! break; ! case XIMP_PREEDITDRAW_TINY: ! _Ximp_CallPreeditDrawCallback3 (ic, ev); ! break; ! case XIMP_PREEDITCARET: ! _Ximp_CallPreeditCaretCallback (ic, ev); ! break; ! case XIMP_STATUSSTART: ! _Ximp_CallStatusStartCallback (ic, ev); ! break; ! case XIMP_STATUSDONE: ! _Ximp_CallStatusDoneCallback (ic, ev); ! break; ! case XIMP_STATUSDRAW: ! _Ximp_CallStatusDrawCallback (ic, ev); ! break; ! case XIMP_STATUSDRAW_CM: ! _Ximp_CallStatusDrawCallback2 (ic, ev); ! break; ! default: ! break; ! } } static Bool _Ximp_ProtoReceive (d, w, ev, client_data) ! Display *d; ! Window w; ! XClientMessageEvent *ev; ! XPointer *client_data; { ! XKeyEvent kev; ! if (ev->message_type != _Ximp_Protocol_id ()) ! return (False); ! if (ev->format == 32) { ! switch (ev->data.l[0]) { ! case XIMP_KEYPRESS: ! if( _Ximp_ProcKeypress (d, w, ev, &kev) ) ! XPutBackEvent(d, (XEvent *)&kev); ! else ! return( False ); ! break ; ! case XIMP_CREATE_RETURN: ! _Ximp_ProcCreateReturn (d, w, ev); ! break; ! case XIMP_CONVERSION_BEGIN: ! _Ximp_ProcConversionBegin (d, w, ev); ! break; ! case XIMP_CONVERSION_END: ! _Ximp_ProcConversionEnd (d, w, ev); ! break; ! case XIMP_READPROP: ! _Ximp_ProcReadProperty (d, w, ev); ! _Ximp_MakeKeypress (d, w, ev); ! ev->send_event = False ; ! XPutBackEvent(d, (XEvent *)ev); ! break ; ! case XIMP_ERROR: ! _Ximp_ProcError (NULL, d, w, ev); ! break; ! case XIMP_GEOMETRY: ! case XIMP_PREEDITSTART: ! case XIMP_PREEDITDONE: ! case XIMP_PREEDITDRAW: ! case XIMP_PREEDITDRAW_CM: ! case XIMP_PREEDITCARET: ! case XIMP_STATUSSTART: ! case XIMP_STATUSDONE: ! case XIMP_STATUSDRAW: ! case XIMP_STATUSDRAW_CM: ! _Ximp_CallCallback (d, w, ev); ! break; ! case XIMP_EXTENSION: ! _Ximp_ProcExtension(d, w, ev); ! break; ! default: ! break; ! } ! } else if (ev->format == 8) { ! _Ximp_ProcReadMessage (d, w, ev); ! _Ximp_MakeKeypress (d, w, ev); ! ev->send_event = False ; ! XPutBackEvent(d, (XEvent *)ev); ! } ! return (True); } static Bool _Ximp_ServerDestroy (d, w, ev, client_data) ! Display *d; ! Window w; ! XEvent *ev; ! XPointer *client_data; { ! extern Ximp_XIM *Ximp_Xim_List; ! extern int Ximp_Xim_count; ! register int i; ! register XIMXimpRec *ximp_impart; ! register XIC ic; ! long dummy_mask; ! for(i=0; i < Ximp_Xim_count; i++) { ! if(Ximp_Xim_List[i] != NULL && ! Ximp_Xim_List[i]->ximp_impart->fe_window == w) ! ximp_impart = Ximp_Xim_List[i]->ximp_impart; ! else ! continue; ! _XUnregisterFilter(d, w, _Ximp_XimFilter_Destroy, (XPointer)NULL); ! _Ximp_SetupFreeExtension(Ximp_Xim_List[i]); ! _Ximp_SetupFree(ximp_impart->im_proto_vl, ximp_impart->im_styles, ! ximp_impart->im_keyslist, ximp_impart->im_server_name, ximp_impart->im_server_vl, ximp_impart->im_vendor_name, ximp_impart->im_ext_list); ! ximp_impart->connectserver = 0; ! ximp_impart->fe_window = (Window)NULL; ! for(ic = Ximp_Xim_List[i]->core.ic_chain; ic; ic = ic->core.next) { ! ((Ximp_XIC)ic)->ximp_icpart->icid = NULL; ! _Ximp_CallDestroyCallbackExtension( ic ); ! _XUnregisterFilter(d, ! ic->core.focus_window, ! _Ximp_XimFilter_Client, ! NULL); ! if(((Ximp_XIC)ic)->ximp_icpart->input_mode) {/* ON : input_mode */ ! dummy_mask = ((Ximp_XIC)ic)->ximp_icpart->back_mask; ! XSelectInput(ic->core.im->core.display, ! ic->core.focus_window, dummy_mask); ! ((Ximp_XIC)ic)->ximp_icpart->input_mode = 0; ! } ! } } ! XFlush (d); ! return (False); } Bool _Ximp_XimFilter_Keypress (d, w, ev, client_data) ! Display *d; ! Window w; ! XEvent *ev; ! XPointer client_data; { ! #define BUFFLIM 32 ! KeySym ks; ! char buff[BUFFLIM]; ! XLookupString( (XKeyEvent *)ev, buff, BUFFLIM, &ks, NULL ); ! return( _Ximp_StartXIMP( (Ximp_XIC)client_data, ev, ks ) ); } /* --- 141,1518 ---- return( False ); } + Bool + _Ximp_CMPredicate32(d, ev, arg0) + Display *d; + XEvent *ev; + XPointer arg0; + { + XimpCMPredicateArg arg = (XimpCMPredicateArg)arg0; + + if(ev->type == ClientMessage ) { + if(ev->xclient.message_type == arg->type && + ev->xclient.format == 32 ) { + if(arg->icid == 0 || ISCMOf(ev,1,arg->icid)) + if(ISCMOf(ev,0,arg->protocol) || + ISXIMP_ERROR(ev)) + return(True); + } + } else if( ev->type == DestroyNotify) { + if( ev->xdestroywindow.window == arg->owner ) { + return( True ); + } + } + return( False ); + } + + Bool + _Ximp_CMPredicate8(d, ev, arg0) + Display *d; + XEvent *ev; + XPointer arg0; + { + ICID icid; + long nicid; + XimpCMPredicateArg arg = (XimpCMPredicateArg)arg0; + + if (ev->type == ClientMessage) { + if (ev->xclient.message_type == arg->type) { + if (ev->xclient.format == 8) { + nicid = *(unsigned long *)(&(ev->xclient.data.b[0])); + icid = (ICID)ntohl(nicid); + if (icid == arg->icid) + return(True); + } else if(arg->icid == 0 || ISCMOf(ev,1,arg->icid)) + if(ISXIMP_ERROR(ev)) + return(True); + } + } else if (ev->type == DestroyNotify) { + if (ev->xdestroywindow.window == arg->owner) { + return(True); + } + } + return(False); + } + + static Bool + combine_multiple_cm( ev, buf, len ) + XClientMessageEvent *ev; + unsigned char **buf; + int *len; + { + register int i; + unsigned char *p; + register int rlen = (int)((unsigned char)ev->data.b[4]); + register int ct_len; + + ct_len = 5 + ((rlen <= CT_MAX_IN_CM) ? rlen : CT_MAX_IN_CM); + + if( *buf == NULL ) { + if( (*buf = (unsigned char *)Xmalloc(rlen + 1)) == NULL ) + return( False ); + *len = rlen; + } + for( p = *buf + *len - rlen, i = 5; i < ct_len; i++ ) + *p++ = ev->data.b[i]; + *p = '\0'; + return((rlen <= CT_MAX_IN_CM) ? False : True); + } + + int + _Ximp_CombineMultipleCM( ic, ct ) + Ximp_XIC ic; + unsigned char **ct; + { + XimpCMPredicateArgRec Arg; + int len = 0; + XEvent ev; + + Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; + Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; + Arg.icid = ic->ximp_icpart->icid; + + *ct = NULL; + while( True ) { + if( !_XimpIfEvent( ic, &ev, _Ximp_CMPredicate8, (XPointer)&Arg ) ) { + if( len != 0 ) { + XFree( *ct ); + *ct = NULL; + } + break; + } + if( !combine_multiple_cm( &ev, ct, &len ) ) { + if( len == 0 && ev.xclient.data.b[4] != 0 ) { + for(;;) { + if( _XimpCheckIfEvent( ic, &ev, _Ximp_CMPredicate8, + (XPointer)&Arg ) ) { + if( (unsigned)ev.xclient.data.b[4] <= CT_MAX_IN_CM ) + break; + } + else { + if( ev.type != LASTEvent ) + break; + } + } + } + break; + } + } + return( len ); + } + static unsigned char * ! _Ximp_Reset( ic, length ) ! Ximp_XIC ic; ! int *length; { ! XEvent Message; ! XEvent event; XimpCMPredicateArgRec Arg; int rval; Atom actual_type_return; int actual_format_return; ! unsigned long nitems; ! unsigned long bytes_after_return; unsigned char *p = NULL; ! *length = 0; ! if(!(IS_IC_CONNECTED(ic) && IS_BEING_PREEDITED(ic))) ! return( (unsigned char *)NULL ); + /* ClientMessage Send */ + _Ximp_IM_SendMessage( ic, XIMP_RESET(ic), NULL, NULL, NULL ); + + if(ISXimp4(ic) && !ISTYPE2(ic)) { Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; ! Arg.protocol = XIMP_SPROC_STOPPED(ic); Arg.icid = ic->ximp_icpart->icid; ! if(_XimpIfEvent(ic, &event, _Ximp_CMPredicate32, (XPointer)&Arg)) { ! _Ximp_ServerProcessStopped(((Ximp_XIM)ic->core.im)->core.display, ! ic->core.focus_window, ! &event); ! } ! } ! Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; ! Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; ! Arg.protocol = XIMP_RESET_RETURN(ic); ! Arg.icid = ic->ximp_icpart->icid; ! _Ximp_Q_align(ic, &Arg, True); ! if( !_XimpIfEvent( ic, &event, _Ximp_CMPredicate32, (XPointer)&Arg ) ) ! return( NULL ); ! if( ISXimp4(ic) ) { ! switch( event.xclient.data.l[XIMP4_RESET_RETURN_DETAIL] ){ ! default: ! break; ! ! case NO_RESET_DATA: return( NULL ); + break; ! case RESET_DATA_VIA_CM: ! *length = _Ximp_CombineMultipleCM( ic, &p ); ! return( p ); ! break; ! ! case RESET_DATA_VIA_PROP: ! if( XGetWindowProperty( ic->core.im->core.display, ! ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window, ! (Atom)event.xclient.data.l[XIMP_RESET_RETURN_ATOM(ic)], ! 0L, 1000000L, True, AnyPropertyType, &actual_type_return, ! &actual_format_return, &nitems, ! &bytes_after_return, &p) == Success ) { ! *length = nitems; ! return( p ); ! } ! break; ! } } ! else { ! if( XGetWindowProperty( ic->core.im->core.display, ! ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window, ! (Atom)event.xclient.data.l[XIMP_RESET_RETURN_ATOM(ic)], ! 0L, 1000000L, True, AnyPropertyType, &actual_type_return, ! &actual_format_return, &nitems, ! &bytes_after_return, &p ) == Success ) { ! *length = nitems; ! return( p ); ! } ! } ! return( NULL ); } char * ! _Ximp_MbReset( ic ) ! Ximp_XIC ic; { ! char *mb; ! int length = 0; ! unsigned char *ct = _Ximp_Reset( ic, &length ); ! if( !ct ) ! return( NULL ); ! if( (mb = Xmalloc(length+1)) == NULL ) { ! Xfree( ct ); ! return( NULL ); ! } ! _Ximp_cttombs( ic->core.im->core.lcd, ct, strlen((char *)ct), mb, &length, NULL ); ! Xfree( ct ); ! mb[length] = '\0'; ! return( mb ); } wchar_t * ! _Ximp_WcReset( ic ) ! Ximp_XIC ic; { ! wchar_t *wc; ! int length = 0; ! unsigned char *ct = _Ximp_Reset( ic, &length ); ! if( !ct ) ! return( NULL ); ! if( (wc = (wchar_t *)Xmalloc((length+1) * sizeof(wchar_t))) == NULL ) { ! Xfree( ct ); ! return( NULL ); ! } ! _Ximp_cttowcs( ic->core.im->core.lcd, ct, strlen((char *)ct), wc, &length, NULL ); ! Xfree( ct ); ! wc[length] = (wchar_t)0; ! return( wc ); } + #define LookupNothing 0 #define LookupKeypress 1 #define LookupProperty 2 #define LookupMessage 3 ! static int _xim_lookup_sign = LookupNothing; ! static unsigned long _xim_message_len = 0; ! static unsigned char *_xim_message_buff = (unsigned char *)NULL; ! static Ximp_XIC _xim_message_ic = (Ximp_XIC)NULL; int _Ximp_MbLookupString(ic, ev, buffer, bytes, keysym, status) ! Ximp_XIC ic; ! XKeyEvent *ev; ! char *buffer; ! int bytes; ! KeySym *keysym; ! Status *status; { ! XComposeStatus *comp_status = NULL; ! int ret = 0, len; ! XimpLCd lcd; ! unsigned char *s; ! int str_len; ! u_char *bufp; ! if(ev->type == KeyPress && ev->keycode == 0) { /* Filter function */ ! if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { ! if(status) *status = XLookupNone; ! _xim_lookup_sign = LookupNothing; ! _xim_message_len = 0; ! return(0); } ! if ( _xim_message_ic == ic && ! ((_xim_lookup_sign == LookupProperty) || (_xim_lookup_sign == LookupMessage))) { ! s = _xim_message_buff; ! str_len = _xim_message_len; ! lcd = (XimpLCd)ic->core.im->core.lcd; ! len = _Ximp_ct_mbslen(lcd, s, str_len, NULL); ! if (len > bytes) { ! ret = len; ! if(status) *status = XBufferOverflow; ! return(ret); /* Immidiately return */ ! } else if (_Ximp_cttombs(lcd, s, str_len, ! buffer, &bytes, NULL) <= 0) { ! ret = 0; ! if(status) *status = XLookupNone; ! } else { ! ret = bytes; ! if(status) *status = XLookupChars; ! } ! XFree( _xim_message_buff ); ! _xim_message_buff = NULL; ! _xim_message_len = 0; ! _xim_lookup_sign = LookupNothing; ! return(ret); ! } else { ! if(status) *status = XLookupNone; ! return(0); ! } ! } else if(ev->type == KeyPress) { ! ic->ximp_icpart->putback_key_event = False; ! if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { ! if(status) *status = XLookupNone; ! return(0); ! } ! ret = _Ximp_LookupMBText(ic, ev, buffer, bytes, keysym, comp_status); ! if(ret > 0) { ! if(keysym && *keysym != NoSymbol) { ! if(status) *status = XLookupBoth; ! } else { ! if(status) *status = XLookupChars; ! } ! } else { ! if(keysym && *keysym != NoSymbol) { ! if(status) *status = XLookupKeySym; ! } else { ! if(status) *status = XLookupNone; ! } ! } ! } else { ! if (status) *status = XLookupNone; ! } ! return(ret); } int _Ximp_WcLookupString(ic, ev, buffer, wlen, keysym, status) ! Ximp_XIC ic; ! XKeyEvent *ev; ! wchar_t *buffer; ! int wlen; ! KeySym *keysym; ! Status *status; { ! XComposeStatus *comp_status = NULL; ! int ret, len; ! char look[128]; ! XimpLCd lcd; ! unsigned char *s; ! int str_len; ! if(ev->type == KeyPress && ev->keycode == 0) { /* Filter function */ ! if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { ! if(status) *status = XLookupNone; ! _xim_lookup_sign = LookupNothing; ! _xim_message_len = 0; ! return(0); } ! if ( _xim_message_ic == ic && ! ((_xim_lookup_sign == LookupProperty) || (_xim_lookup_sign == LookupMessage))) { ! s = _xim_message_buff; ! str_len = _xim_message_len; ! lcd = (XimpLCd)ic->core.im->core.lcd; ! len = _Ximp_ct_wcslen(lcd, s, str_len, NULL); ! if (len > wlen) { ! ret = len; ! if(status) *status = XBufferOverflow; ! return(ret); /* Immidiately return */ ! } else if (_Ximp_cttowcs(lcd, s, str_len, ! buffer, &wlen, NULL) <= 0) { ! ret = 0; ! if(status) *status = XLookupNone; ! } else { ! ret = wlen; ! if(status) *status = XLookupChars; ! } ! XFree( _xim_message_buff ); ! _xim_message_buff = NULL; ! _xim_message_len = 0; ! _xim_lookup_sign = LookupNothing; ! return(ret); ! } else { ! if(status) *status = XLookupNone; ! return(0); ! } ! } else if(ev->type == KeyPress) { ! ic->ximp_icpart->putback_key_event = False; ! if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { ! if(status) *status = XLookupNone; ! return(0); ! } ! ret = _Ximp_LookupWCText(ic, ev, buffer, wlen, keysym, comp_status); ! if(ret > 0) { ! if(keysym && *keysym != NoSymbol) { ! if(status) *status = XLookupBoth; ! } else { ! if(status) *status = XLookupChars; ! } ! } else { ! if(keysym && *keysym != NoSymbol) { ! if(status) *status = XLookupKeySym; ! } else { ! if(status) *status = XLookupNone; ! } ! } ! } else { ! if (status) *status = XLookupNone; ! } ! return(ret); } static Bool _Ximp_FocusInput (window, mask) ! Window window; ! unsigned long *mask; { ! int i; ! Ximp_XIM pim; ! Ximp_XIC pic; ! extern int Ximp_Xim_count; ! extern Ximp_XIM *Ximp_Xim_List; ! for(i = 0; i < Ximp_Xim_count; i++) { ! if((pim = Ximp_Xim_List[i]) == NULL) ! continue ; ! for (pic = (Ximp_XIC)pim->core.ic_chain; ! pic; pic = (Ximp_XIC)pic->core.next) { ! if(pic->core.focus_window == window && IS_BEING_PREEDITED(pic)) { ! *mask = pic->ximp_icpart->back_mask; ! return(True); ! } } ! } ! return (False); } + void + _Ximp_GetFocusWindowSelectMask(ic, client_window, mask) + Ximp_XIC ic; + Window client_window; + unsigned long *mask; + { + Display *d = ic->core.im->core.display; + XWindowAttributes ret_attributes; + + if(!(XIMP_CHK_FOCUSWINMASK(ic))) { + XGetWindowAttributes(d, client_window, &ret_attributes); + *mask = ret_attributes.your_event_mask; + return; + } + if (!(_Ximp_FocusInput (ic->core.focus_window, mask))) { + XGetWindowAttributes(d, ic->core.focus_window, &ret_attributes); + *mask = ret_attributes.your_event_mask; + } + return; + } + static Bool ! isRegisterdKey(list, ev) ! Ximp_KeyList *list ; ! XKeyEvent *ev; { ! #define BUFFLIM 32 ! register i; ! KeySym keysym; ! char buff[BUFFLIM]; ! XLookupString( (XKeyEvent *)ev, buff, BUFFLIM, &keysym, NULL ); ! ! if(!keysym || list == NULL) return False ; ! for(i = 0 ; i < (int)list->count_keys; i++) { ! if((keysym == list->keys_list[i].keysym) ! && ((ev->state & list->keys_list[i].modifier_mask) ! == list->keys_list[i].modifier ) ){ ! return True ; } + } + return False ; + } ! static Bool ! isOnEvent(ic, ev) ! Ximp_XIC ic ; ! XEvent *ev ; ! { ! Ximp_KeyList *list = ((Ximp_XIM)ic->core.im)->ximp_impart->im_keyslist ; ! if(isRegisterdKey(list, ev)){ ! return True ; ! } else if(IS_IC_CONNECTED(ic)){ ! return False ; ! } ! list = ((Ximp_XIM)ic->core.im)->ximp_impart->process_start_keys ; ! return isRegisterdKey(list, ev) ; ! } ! static Bool ! isOffEvent(ic, ev) ! Ximp_XIC ic ; ! XEvent *ev ; ! { ! Ximp_KeyList *list = ((Ximp_XIM)ic->core.im)->ximp_impart->im_offkeyslist ; ! if(isRegisterdKey(list, ev)){ ! return True ; ! } ! return False ; ! } ! #define DEFAULT_QUE_SIZE (16) ! #define QUE_SIZE_INCREMENT (4) ! /* ! * Queueing the XIMProtocols for specified IC until specified XIMProtocol has reached ! */ ! ! _Ximp_Q_align(ic, Arg, enque_proto) ! Ximp_XIC ic; ! XimpCMPredicateArgRec *Arg; ! Bool enque_proto; /* Flag for enqueing the sync protocol */ ! { ! static XEvent *ev_que = NULL; ! static int que_size = 0; ! int qued = 0; ! XEvent ev_buf, *event_return = &ev_buf, *new; ! ! if (ev_que == (XEvent *)NULL) { ! if (ev_que = (XEvent *)Xcalloc(DEFAULT_QUE_SIZE, sizeof(XEvent))) { ! que_size = DEFAULT_QUE_SIZE; } ! } ! while (True) { ! XIfEvent(ic->core.im->core.display, event_return, _Ximp_CMPredicateAll, (char *)Arg); ! if( event_return->type == DestroyNotify ) { ! XPutBackEvent( ic->core.im->core.display, event_return ); ! break; ! } else if(ISXIMP_ERROR(event_return)) { ! XPutBackEvent( ic->core.im->core.display, event_return ); ! break; ! } else if (event_return->type == ClientMessage) { ! if(event_return->xclient.message_type == Arg->type && ! event_return->xclient.format == 32 ) { ! if(Arg->icid == 0 || ISCMOf(event_return,1,Arg->icid)) ! if(ISCMOf(event_return,0,Arg->protocol)) { ! if (enque_proto) ! XPutBackEvent( ic->core.im->core.display, event_return ); ! break; ! } ! } ! } ! if (qued == que_size) { /* Que is full */ ! if (new = (XEvent *)Xrealloc(ev_que, sizeof(XEvent) * (que_size + QUE_SIZE_INCREMENT))) { ! ev_que = new; ! que_size += QUE_SIZE_INCREMENT; ! } ! } ! /* If not enough memory for ev_que, some protocol dropped */ ! if (qued == que_size) continue; ! /* Enque */ ! bcopy(event_return, &ev_que[qued], sizeof(XEvent)); ! qued++; ! } ! /* Deque */ ! while (qued > 0) { ! qued--; ! XPutBackEvent(ic->core.im->core.display, &ev_que[qued]); ! } } ! static Bool ! _Ximp_ForwardEvent(ic, ev) ! Ximp_XIC ic; ! XKeyEvent *ev; { XimpCMPredicateArgRec Arg; + if(ISXimp4(ic)){ + if(ISFE3(ic)){ + if(ev->window != ic->core.focus_window) { + _Ximp_IM_SendMessage(ic, XIMP_KEYPRESS(ic), + (long)ev->keycode, + (long)ev->state, (Time)ev->time ); + } + if(isOffEvent(ic,ev)){ + Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; + Arg.icid = ic->ximp_icpart->icid; + Arg.protocol = XIMP_SPROC_STOPPED(ic); + Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; + _Ximp_Q_align(ic, &Arg, True); + } + } else { + if(ISFE2(ic) && (ev->window == ic->core.focus_window)) { + ; /* Un expected event */ + } else { + _Ximp_IM_SendMessage(ic, XIMP_KEYPRESS(ic), + (long)ev->keycode, + (long)ev->state, (Time)ev->time ); + } + if( ISSYNC(ic) ) { + Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; + Arg.icid = ic->ximp_icpart->icid; + Arg.protocol = XIMP_KEYPRESS_RETURN(ic); + Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; + _Ximp_Q_align(ic, &Arg, False) ; + } + } + } else { + _Ximp_IM_SendMessage(ic, XIMP_KEYPRESS(ic), + (long)ev->keycode, + (long)ev->state, NULL); + } + return(FILTERD); + } + + static void + _Ximp_RegKeyPressed( ic, ev ) + Ximp_XIC ic; + XKeyEvent *ev; + { + unsigned long dummy_mask; + XWindowAttributes ret_attributes; + XimpCMPredicateArgRec Arg; + Bool is_SelectInput_needed = False; + + if(ISXimp4(ic)) { + if(ISFE1(ic) || (IS_FORCESELECTKEYRELEASE(ic->core.im) && ISBE1(ic))) + is_SelectInput_needed = True; + } else if(ISXIMP3FE(ic)) { + is_SelectInput_needed = True; + } + if(is_SelectInput_needed) { + if (_Ximp_FocusInput (ic->core.focus_window, &dummy_mask)) { + ic->ximp_icpart->back_mask = dummy_mask; + } else { + Display *d = ic->core.im->core.display; + + XGetWindowAttributes(d, ic->core.focus_window, &ret_attributes); + dummy_mask = ret_attributes.your_event_mask; + ic->ximp_icpart->back_mask = dummy_mask; + } + if(ISXimp4(ic)) { + if(ISFE1(ic)) + dummy_mask &= ~(KeyPressMask|KeyReleaseMask); + else { /* (IS_FORCESELECTKEYRELEASE(ic->core.im) && ISBE1(ic)) */ + dummy_mask |= KeyReleaseMask; + } + } else if(ISXIMP3FE(ic)) { + dummy_mask &= ~(KeyPressMask|KeyReleaseMask); + } + XSelectInput(ic->core.im->core.display, ic->core.focus_window, dummy_mask); + } + _Ximp_IM_SendMessage(ic, XIMP_MOVE(ic), + ic->ximp_icpart->preedit_attr.SpotLocation.x, + ic->ximp_icpart->preedit_attr.SpotLocation.y, + NULL); + if( (ISXimp4(ic) && ISTYPE2(ic)) ) { + Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; + Arg.icid = ic->ximp_icpart->icid; + Arg.protocol = XIMP_KEYPRESS_RETURN(ic); + Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; + _Ximp_IM_SendMessage(ic, XIMP_KEYPRESS(ic), + (long)ev->keycode, + (long)ev->state, (Time)ev->time ); + if( ISSYNC(ic) ) + _Ximp_Q_align(ic, &Arg, False) ; + } else { + _Ximp_IM_SendMessage(ic, XIMP_REG_KEY_PRESSED(ic), NULL, NULL, NULL); + } + ic->ximp_icpart->input_mode = BEING_PREEDITED; + XFlush(ic->core.im->core.display); + } + + static Bool + _Ximp_KeypressFilter( ic, ev ) + Ximp_XIC ic; + XKeyEvent *ev; + { + Bool isFilterd = False; + + if (IS_FABLICATED(ic,ev)){ + ic->ximp_icpart->putback_key_event = False; + return NOTFILTERD ; + } + if(IS_IC_CONNECTED(ic)) { + if(IS_BEING_PREEDITED(ic)) { + return _Ximp_ForwardEvent(ic, ev); + } + if(isOnEvent(ic, ev)){ + _Ximp_RegKeyPressed( ic, ev ); + return FILTERD; + } + return NOTFILTERD; + } else if(IS_RECONNECTABLE(ic->core.im)) { + if(isOnEvent(ic, ev)){ + if(!IS_SERVER_CONNECTED(ic->core.im)) { + if(!(isFilterd = _Ximp_ConnectServer(ic->core.im))) + return(NOTFILTERD); + } + isFilterd = _Ximp_ConnectIC(ic, XIMP_START_IC); + } + if(!isFilterd) return(NOTFILTERD); + + _Ximp_RegKeyPressed( ic, ev ); + + if(IS_RESTARTABLE(ic->core.im)) { + _Ximp_CallRestartCallbackExtension(ic); + } + return FILTERD; + } + return(NOTFILTERD); + } + + static Bool + _Ximp_KeyreleaseFilter( ic, ev ) + Ximp_XIC ic; + XKeyEvent *ev; + { + XimpCMPredicateArgRec Arg; + + if (IS_FABLICATED(ic,ev)){ + ic->ximp_icpart->putback_key_event = False; + return NOTFILTERD ; + } + if(!IS_IC_CONNECTED(ic)) + return(NOTFILTERD); + if(ISXimp4(ic)) { + if(ISFRONTEND(ic) && (!(ic->ximp_icpart->back_mask & KeyReleaseMask))){ + ic->ximp_icpart->back_mask |= KeyReleaseMask ; + _Ximp_IM_SendMessage(ic, XIMP_EVENTMASK_NOTIFY(ic), + ic->ximp_icpart->back_mask, + NULL, NULL ); + Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; + Arg.icid = ic->ximp_icpart->icid; + Arg.protocol = XIMP_EVENTMASK_NOTIFY_RETURN(ic); + Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; + _Ximp_Q_align(ic, &Arg, False); + } + if((ISTYPE1(ic) || ISFE3(ic)) && (!IS_BEING_PREEDITED(ic))) + return(NOTFILTERD); + if(ISFE3(ic) && (ev->window == ic->core.focus_window)) + return(FILTERD); + + _Ximp_IM_SendMessage(ic, XIMP_KEYRELEASE(ic), + (long)ev->keycode, + (long)ev->state, (Time)ev->time ); + if( ISSYNC(ic) ) { + Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; + Arg.icid = ic->ximp_icpart->icid; + Arg.protocol = XIMP_KEYRELEASE_RETURN(ic); + Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; + _Ximp_Q_align(ic, &Arg, False) ; + } + return(FILTERD); + } + return(NOTFILTERD); + } + + Bool + _Ximp_ConnectIC(ic, mode) + Ximp_XIC ic; + int mode; + { + unsigned long mask; + XEvent event; + XimpCMPredicateArgRec Arg; + long *type_p; + Display *display = ic->core.im->core.display; + unsigned long dummy_mask; + XWindowAttributes ret_attributes; + Bool is_SelectInput_needed = False; + if(mode == XIMP_CREATE_IC) { /* XCretaeIC() */ if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { ! ic->core.client_window = XCreateSimpleWindow( display, ! DefaultRootWindow(ic->core.im->core.display), ! 0, 0, 1, 1, 1, 0, 0); } } ! if(!(XIMP_CHK_FOCUSWINMASK(ic))) { ic->core.focus_window = ic->core.client_window; } ! /* Property Data Set */ ! XChangeProperty(display, ic->core.client_window, ((Ximp_XIM)ic->core.im)->ximp_impart->version_id, XA_STRING, 8, PropModeReplace, (unsigned char *)XIMP_PROTOCOL_VERSION, strlen(XIMP_PROTOCOL_VERSION)); ! XFlush(display); ! mask = XIMP_PROTO_MASK2(ic); ! dummy_mask = NULL; ! /* Put XIMP_TYPE Property for Ximp4.0 */ ! if(ISXimp4(ic)){ ! for(type_p = ((Ximp_XIM)ic->core.im)->ximp_impart->type_list; *type_p; type_p++) { ! if(*type_p == (long)ic->ximp_icpart->svr_mode) ! break; ! } ! if(*type_p != NULL) { ! XChangeProperty(display, ic->core.client_window, ! ((Ximp_XIM)ic->core.im)->ximp_impart->type_id, ! ((Ximp_XIM)ic->core.im)->ximp_impart->type_id, ! 32, PropModeReplace, (unsigned char *)type_p, 1); ! mask |= XIMP_SERVERTYPE_MASK4; ! } ! if(ISFRONTEND(ic)) { ! if (_Ximp_FocusInput(ic->core.focus_window, &dummy_mask)) ! ic->ximp_icpart->back_mask = dummy_mask; ! else { ! XGetWindowAttributes(display, ic->core.focus_window, &ret_attributes); ! dummy_mask = ret_attributes.your_event_mask; ! ic->ximp_icpart->back_mask = dummy_mask; ! } ! } ! } ! ! _Ximp_SetFocusWindowProp(ic); ! _Ximp_SetFocusWindowFilter(ic); ! mask |= XIMP_FOCUS_WIN_MASK(ic); if(!( (ic->core.input_style & XIMPreeditCallbacks) || (ic->core.input_style & XIMPreeditNone) ) ) { ! if(mask & XIMP_PROP_PREEDIT(ic)) ! _Ximp_SetPreeditAtr(ic); ! if(mask & XIMP_PROP_PREFONT(ic)) ! _Ximp_SetPreeditFont(ic); ! } else { ! mask &= ~(XIMP_PROP_PREEDIT(ic) | XIMP_PROP_PREFONT(ic)); } if(!( (ic->core.input_style & XIMStatusCallbacks) || (ic->core.input_style & XIMStatusNone) ) ) { ! if(mask & XIMP_PROP_STATUS(ic)) _Ximp_SetStatusAtr(ic); ! if(mask & XIMP_PROP_STSFONT(ic)) _Ximp_SetStatusFont(ic); + } else { + mask &= ~(XIMP_PROP_STATUS(ic) | XIMP_PROP_STSFONT(ic)); } ! /* XIMP_CREATE ClientMessage Send */ ! _Ximp_IM_SendMessage(ic, XIMP_CREATE(ic), ic->core.input_style, mask, ! dummy_mask); Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; ! Arg.protocol = XIMP_CREATE_RETURN(ic); Arg.icid = 0; ! if(_XimpIfEvent(ic, &event, _Ximp_CMPredicate32, (XPointer)&Arg)){ ic->ximp_icpart->icid = (ICID)event.xclient.data.l[1]; ! if(ISXimp4(ic)){ ! if(ISFE2(ic) || (IS_FORCESELECTKEYRELEASE(ic->core.im) && ISBE2(ic))) { ! is_SelectInput_needed = True; ! if(ISFE2(ic)) ! dummy_mask &= ~(KeyPressMask | KeyReleaseMask); ! else { /* IS_FORCESELECTKEYRELEASE(ic->core.im) && ISBE2(ic) */ ! dummy_mask |= KeyReleaseMask; ! } ! } ! ic->ximp_icpart->input_mode = ISTYPE2(ic) ? BEING_PREEDITED : BEING_BYPASSED; ! _Ximp_A_CreateExtension(ic); ! if(is_SelectInput_needed) ! XSelectInput(display, ic->core.focus_window, dummy_mask); ! return True; ! } else { /* Ximp3.5 */ ! _Ximp_A_CreateExtension(ic); ! return True; } } + XDeleteProperty(display, ic->core.client_window, + ((Ximp_XIM)ic->core.im)->ximp_impart->focus_win_id); + if(!((ic->core.input_style & XIMPreeditCallbacks) || + (ic->core.input_style & XIMPreeditNone)) ) { + if(mask & XIMP_PROP_PREEDIT(ic)) + XDeleteProperty(display, ic->core.client_window, + ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id); + if(mask & XIMP_PROP_PREFONT(ic)) + XDeleteProperty(display, ic->core.client_window, + ((Ximp_XIM)ic->core.im)->ximp_impart->preeditfont_id); + } + if(!((ic->core.input_style & XIMStatusCallbacks) || + (ic->core.input_style & XIMStatusNone))) { + if(mask & XIMP_PROP_STATUS(ic)) + XDeleteProperty(display, ic->core.client_window, + ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id); + if(mask & XIMP_PROP_STSFONT(ic)) + XDeleteProperty(display, ic->core.client_window, + ((Ximp_XIM)ic->core.im)->ximp_impart->statusfont_id); + } + return False ; } void _Ximp_MakeKeypress (d, w, ev) ! Display *d; ! Window w; ! XKeyEvent *ev; { ! ev->type = KeyPress; ! ev->keycode = 0; } ! static Bool ! _Ximp_ProcKey(d, w, ev, kev, type) ! Display *d; ! Window w; ! XClientMessageEvent *ev; ! XKeyEvent *kev; ! int type; { ! ICID icid = ev->data.l[1]; ! Ximp_XIC ic; ! if((ic = _Ximp_LookupXIC(icid)) == NULL) ! return False; ! kev->type = type; ! kev->serial = ev->serial; ! kev->send_event = False; ! kev->display = ev->display; ! kev->window = ev->window; ! kev->root = DefaultRootWindow(ev->display); ! kev->subwindow = (Window)NULL; ! kev->time = ev->data.l[4]; ! kev->x = 0; ! kev->y = 0; ! kev->x_root = 0; ! kev->y_root = 0; ! kev->keycode = ev->data.l[2]; ! kev->state = ev->data.l[3]; ! kev->same_screen = True; ! if(IS_BEING_PREEDITED(ic)) { ! ic->ximp_icpart->putback_key_event = True; ! } ! return True; } static void _Ximp_ProcCreateReturn (d, w, ev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid; ! icid = ev->data.l[1]; } static void ! _Ximp_ServerProcessStarted (d, w, ev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid = ev->data.l[1]; ! Ximp_XIC ic = _Ximp_LookupXIC(icid); ! XWindowAttributes ret_attributes; ! unsigned long mask; ! Bool is_SelectInput_needed = False; ! if(!ic || IS_BEING_PREEDITED(ic)) ! return; ! if(ISXimp4(ic)) { ! if(ISFE1(ic) || (IS_FORCESELECTKEYRELEASE(ic->core.im) && ISBE1(ic))) ! is_SelectInput_needed = True; ! } else if(ISXIMP3FE(ic)) { ! is_SelectInput_needed = True; ! } ! if(is_SelectInput_needed) { ! if (_Ximp_FocusInput (ic->core.focus_window, &mask)){ ! ic->ximp_icpart->back_mask = mask; ! } else { ! XGetWindowAttributes(d, ic->core.focus_window, &ret_attributes); ! ic->ximp_icpart->back_mask = mask = ret_attributes.your_event_mask; } ! if(ISXimp4(ic)) { ! if(ISFE1(ic)) ! mask &= ~(KeyPressMask|KeyReleaseMask); ! else { /* (IS_FORCESELECTKEYRELEASE(ic->core.im) && ISBE1(ic)) */ ! mask |= KeyReleaseMask; ! } ! } else if(ISXIMP3FE(ic)) { ! mask &= ~(KeyPressMask|KeyReleaseMask); ! } ! XSelectInput(d, ic->core.focus_window, mask); ! XFlush(d); ! } ! ic->ximp_icpart->input_mode = BEING_PREEDITED; ! return; } ! /* Ximp4.0 */ ! void ! _Ximp_ConvertOn (ic) ! Ximp_XIC ic; { ! XWindowAttributes ret_attributes; ! unsigned long mask; ! if(IS_BEING_PREEDITED(ic)) return; + if(ISFE1(ic) || (IS_FORCESELECTKEYRELEASE(ic->core.im) && ISBE1(ic))) { + if (_Ximp_FocusInput (ic->core.focus_window, &mask)){ + ic->ximp_icpart->back_mask = mask; + } else { + XGetWindowAttributes(ic->core.im->core.display, ic->core.focus_window, &ret_attributes); + ic->ximp_icpart->back_mask = mask = ret_attributes.your_event_mask; + } + if(ISFE1(ic)) + mask &= ~(KeyPressMask|KeyReleaseMask); + else { /* (IS_FORCESELECTKEYRELEASE(ic->core.im) && ISBE1(ic)) */ + mask |= KeyReleaseMask; + } + XSelectInput(ic->core.im->core.display, ic->core.focus_window, mask); + XFlush(ic->core.im->core.display); + } + ic->ximp_icpart->input_mode = BEING_PREEDITED; + return; } static void ! _Ximp_ServerProcessStopped(d, w, ev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid = ev->data.l[1]; ! Ximp_XIC ic = _Ximp_LookupXIC(icid); ! Bool is_SelectInput_needed = False; ! if(!ic) return; ! ! if(ISXimp4(ic)) { ! if(ISFE1(ic)) ! is_SelectInput_needed = True; ! } else if(ISXIMP3FE(ic)) { ! is_SelectInput_needed = True; ! } ! if(is_SelectInput_needed) { ! XSelectInput(d, ic->core.focus_window, ic->ximp_icpart->back_mask ); ! XFlush(d); ! } ! ic->ximp_icpart->input_mode = BEING_BYPASSED; ! return; } + /* Ximp4.0 */ void ! _Ximp_ConvertOff (ic) ! Ximp_XIC ic; { ! if(ISFE1(ic) || (IS_FORCESELECTKEYRELEASE(ic->core.im) && ISBE1(ic))) { ! XSelectInput(ic->core.im->core.display, ! ic->core.focus_window, ic->ximp_icpart->back_mask ); ! XFlush(ic->core.im->core.display); ! } ! ic->ximp_icpart->input_mode = BEING_BYPASSED; ! return; } static void ! _Ximp_ProcReadProperty (d, w, ev) ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid = ev->data.l[1]; ! Atom read_prop = ev->data.l[2]; ! Ximp_XIC ic = _Ximp_LookupXIC(icid); ! int rval; ! Atom actual_type_return; ! int actual_format_return; ! unsigned long nitems_return; ! int i; ! unsigned char *tmp; ! ! if(!ic) return ; ! rval = XGetWindowProperty( d, ! ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window, ! read_prop, 0, 100000L, True, ! AnyPropertyType, &actual_type_return, ! &actual_format_return, &_xim_message_len, ! &nitems_return, &_xim_message_buff ); ! if( rval != Success ) ! return; ! if( (tmp = (unsigned char *)Xrealloc(_xim_message_buff, _xim_message_len + sizeof(long))) == NULL ) { ! XFree( _xim_message_buff ); ! _xim_message_buff = NULL; ! return; ! } ! _xim_message_buff = tmp; ! for( i = 0; i < sizeof(long); i++ ) ! _xim_message_buff[_xim_message_len + i] = (char)NULL; ! _xim_message_ic = ic; ! _xim_lookup_sign = LookupProperty; } ! void ! _Ximp_ProcError (ic0, d, w, ev) ! Ximp_XIC ic0; ! Display *d; ! Window w; ! XClientMessageEvent *ev; { ! ICID icid; ! Ximp_XIC ic; ! unsigned long data[3]; ! /* ! * ToDo: ! * If you want to process the error from IM server, ! * you should modify this routine. ! */ ! if((icid = ev->data.l[1]) != 0) { ! if((ic = _Ximp_LookupXIC(icid)) == NULL) return; ! } else if((ic = ic0) == NULL) ! return; ! ! if (ic->ximp_icpart->error.callback) { ! data[0] = ev->data.l[2]; ! data[2] = ev->data.l[4]; ! if(!ISXIMP_ERROR(ev)) ! data[1] = XIMP_BadProtocol; ! else ! data[1] = ev->data.l[3]; ! (*ic->ximp_icpart->error.callback)(ic, ! ic->ximp_icpart->error.client_data, ! data); ! } } static Bool _Ximp_ProtoReceive (d, w, ev, client_data) ! Display *d; ! Window w; ! XClientMessageEvent *ev; ! XPointer *client_data; { ! XKeyEvent kev; ! Ximp_XIC ic; ! if (ev->message_type != _Ximp_Protocol_id ()) ! return (False); ! if (ev->format == 32) { ! ic = _Ximp_LookupXIC((ev->data.l[1])); ! switch (ev->data.l[0]) { ! case XIMP_KEYPRESS4: ! case XIMP_KEYPRESS3: ! if(ISFE1(ic) && !IS_BEING_PREEDITED(ic)) { ! return(True); ! } ! if(_Ximp_ProcKey(d, w, ev, &kev, KeyPress)) ! XPutBackEvent(d, (XEvent *)&kev); ! else ! return(False); ! break ; ! case XIMP_KEYRELEASE4: ! if(!ISXimp4(ic)) return True ; ! if(!IS_BEING_PREEDITED(ic)) return True ; ! if(!(ic->ximp_icpart->back_mask & KeyReleaseMask)) return True; ! if(_Ximp_ProcKey(d, w, ev, &kev, KeyRelease)) ! XPutBackEvent(d, (XEvent *)&kev); ! else ! return(False); ! break ; ! case XIMP_CREATE_RETURN4: ! case XIMP_CREATE_RETURN3: ! _Ximp_ProcCreateReturn (d, w, ev); ! break; ! case XIMP_SPROC_STARTED4: ! case XIMP_CONVERSION_BEGIN3: ! _Ximp_ServerProcessStarted(d, w, ev); ! break; ! case XIMP_SPROC_STOPPED4: ! case XIMP_CONVERSION_END3: ! _Ximp_ServerProcessStopped(d, w, ev); ! break; ! case XIMP_READPROP4: ! case XIMP_READPROP3: ! if(ISFE1(ic) && !IS_BEING_PREEDITED(ic)) { ! return(True); ! } ! _Ximp_ProcReadProperty (d, w, ev); ! _Ximp_MakeKeypress (d, w, ev); ! ev->send_event = False ; ! XPutBackEvent(d, (XEvent *)ev); ! break ; ! case XIMP_ERROR4: ! case XIMP_ERROR3: ! _Ximp_ProcError (NULL, d, w, ev); ! break; ! case XIMP_GEOMETRY4: ! case XIMP_GEOMETRY3: ! _Ximp_CallGeometryCallback (ic, ev); ! break; ! case XIMP_PREEDITSTART4: ! case XIMP_PREEDITSTART3: ! _Ximp_CallPreeditStartCallback (ic, ev); ! break; ! case XIMP_PREEDITDONE4: ! case XIMP_PREEDITDONE3: ! _Ximp_CallPreeditDoneCallback (ic, ev); ! break; ! case XIMP_PREEDITDRAW4: ! case XIMP_PREEDITDRAW3: ! _Ximp_CallPreeditDrawCallback (ic, ev); ! break; ! case XIMP_PREEDITDRAW_CM4: ! case XIMP_PREEDITDRAW_CM3: ! _Ximp_CallPreeditDrawCallback2 (ic, ev); ! break; ! case XIMP_PREEDITDRAW_CM_TINY4: ! case XIMP_PREEDITDRAW_TINY3: ! _Ximp_CallPreeditDrawCallback3 (ic, ev); ! break; ! case XIMP_PREEDITCARET4: ! case XIMP_PREEDITCARET3: ! _Ximp_CallPreeditCaretCallback (ic, ev); ! break; ! case XIMP_STATUSSTART4: ! case XIMP_STATUSSTART3: ! _Ximp_CallStatusStartCallback (ic, ev); ! break; ! case XIMP_STATUSDONE4: ! case XIMP_STATUSDONE3: ! _Ximp_CallStatusDoneCallback (ic, ev); ! break; ! case XIMP_STATUSDRAW4: ! case XIMP_STATUSDRAW3: ! _Ximp_CallStatusDrawCallback (ic, ev); ! break; ! case XIMP_STATUSDRAW_CM4: ! case XIMP_STATUSDRAW_CM3: ! _Ximp_CallStatusDrawCallback2 (ic, ev); ! break; ! case XIMP_EXTENSION4: ! case XIMP_EXTENSION3: ! _Ximp_ProcExtension(d, w, ev); ! break; ! default: ! break; ! } ! } else if (ev->format == 8) { ! ic = _Ximp_LookupXIC((ICID)ntohl(*(unsigned long *)(&(ev->data.b[0])))); ! if(ISFE1(ic) && !IS_BEING_PREEDITED(ic)) { ! return(True); ! } ! XPutBackEvent( d, (XEvent *)ev ); ! _xim_message_buff = NULL; ! _xim_message_len = _Ximp_CombineMultipleCM( ic, &_xim_message_buff ); ! if( _xim_message_len != 0 ) { ! _xim_lookup_sign = LookupMessage; ! _xim_message_ic = ic; ! _Ximp_MakeKeypress( d, w, ev ); ! ev->send_event = False; ! XPutBackEvent( d, (XEvent *)ev ); ! } ! } ! return (True); } + static + _Ximp_CallbackDestroy(ic, w, ev) + XIC ic ; + Window w; + XEvent *ev; + { + XICXimpRec *xic = ((Ximp_XIC)ic)->ximp_icpart ; + register XIMCallback *pcb = &ic->core.preedit_attr.callbacks.done; + register XIMCallback *scb = &ic->core.status_attr.callbacks.done; + + if((ic->core.input_style & XIMPreeditCallbacks) && pcb->callback && xic->cbstatus & XIMPCBPREEDITACTIVE){ + (*pcb->callback) (ic, pcb->client_data, NULL); + } + if((ic->core.input_style & XIMStatusCallbacks) && scb->callback && xic->cbstatus & XIMPCBSTATUSACTIVE){ + register XIMCallback *cb = &ic->core.status_attr.callbacks.draw; + XIMStatusDrawCallbackStruct CallData; + XIMText cbtext; + + bzero(&CallData, sizeof(XIMStatusDrawCallbackStruct)); + bzero(&cbtext, sizeof(XIMText)); + CallData.data.text = &cbtext; + cbtext.feedback = NULL; + cbtext.encoding_is_wchar = False ; + cbtext.string.multi_byte = DEFAULTCBSTATUSSTRING ; + cbtext.length = strlen(DEFAULTCBSTATUSSTRING) ; + (*cb->callback) (ic, scb->client_data, &CallData); + (*scb->callback) (ic, scb->client_data, NULL); + } + } static Bool _Ximp_ServerDestroy (d, w, ev, client_data) ! Display *d; ! Window w; ! XEvent *ev; ! XPointer *client_data; { ! extern Ximp_XIM *Ximp_Xim_List; ! extern int Ximp_Xim_count; ! register int i; ! register XIMXimpRec *ximp_impart; ! register XIC ic; ! Bool is_SelectInput_needed = False; ! ! for(i=0; i < Ximp_Xim_count; i++) { ! if(Ximp_Xim_List[i] != NULL && ! Ximp_Xim_List[i]->ximp_impart->fe_window == w) ! ximp_impart = Ximp_Xim_List[i]->ximp_impart; ! else ! continue; ! _XUnregisterFilter(d, w, _Ximp_XimFilter_Destroy, (XPointer)NULL); ! _Ximp_SetupFreeExtension(Ximp_Xim_List[i]); ! _Ximp_SetupFree(ximp_impart->im_proto_vl, ximp_impart->im_styles, ! ximp_impart->type_list, ! /* ! * For the reconnection, we should not free those datas. ! */ ! NULL/* ximp_impart->im_keyslist */, ! NULL/*ximp_impart->im_offkeyslist*/, ximp_impart->im_server_name, ximp_impart->im_server_vl, ximp_impart->im_vendor_name, ximp_impart->im_ext_list); ! IS_SERVER_CONNECTED(Ximp_Xim_List[i]) = False; ! ximp_impart->fe_window = (Window)NULL; ! for(ic = Ximp_Xim_List[i]->core.ic_chain; ic; ic = ic->core.next) { ! _Ximp_CallbackDestroy(ic, w, ev); ! _Ximp_CallDestroyCallbackExtension(ic, w, ev); ! ((Ximp_XIC)ic)->ximp_icpart->icid = NULL; ! _XUnregisterFilter(d, ic->core.focus_window, ! _Ximp_XimFilter_Client, NULL); ! if(ISXimp4(ic)) { ! if(ISFE1(ic) || ISFE2(ic) || (IS_FORCESELECTKEYRELEASE(ic->core.im) && ISBACKEND(ic))) ! is_SelectInput_needed = True; ! } else if(ISXIMP3FE(ic)) { ! is_SelectInput_needed = True; ! } ! if(is_SelectInput_needed) { ! XSelectInput(d, ic->core.focus_window, ((Ximp_XIC)ic)->ximp_icpart->back_mask ); ! } ! ((Ximp_XIC)ic)->ximp_icpart->input_mode = BEING_BYPASSED; } ! } ! XFlush (d); ! return (False); } Bool + #if NeedFunctionPrototypes + _Ximp_XimFilter_Keypress ( + Display *d, + Window w, + XEvent *ev, + XPointer client_data + ) + #else _Ximp_XimFilter_Keypress (d, w, ev, client_data) ! Display *d; ! Window w; ! XEvent *ev; ! XPointer client_data; ! #endif { ! return( _Ximp_KeypressFilter( (Ximp_XIC)client_data, ev ) ); ! } ! Bool ! #if NeedFunctionPrototypes ! _Ximp_XimFilter_Keyrelease ( ! Display *d, ! Window w, ! XEvent *ev, ! XPointer client_data ! ) ! #else ! _Ximp_XimFilter_Keyrelease (d, w, ev, client_data) ! Display *d; ! Window w; ! XEvent *ev; ! XPointer client_data; ! #endif ! { ! return( _Ximp_KeyreleaseFilter( (Ximp_XIC)client_data, ev ) ); } /* *************** *** 925,944 **** Bool _Ximp_XimFilter_Client (d, w, ev, client_data) ! Display *d; ! Window w; ! XEvent *ev; ! XPointer *client_data; { ! return(_Ximp_ProtoReceive (d, w, ev, client_data)); } Bool _Ximp_XimFilter_Destroy (d, w, ev, client_data) ! Display *d; ! Window w; ! XEvent *ev; ! XPointer *client_data; { ! return(_Ximp_ServerDestroy (d, w, ev, client_data)); } --- 1525,1544 ---- Bool _Ximp_XimFilter_Client (d, w, ev, client_data) ! Display *d; ! Window w; ! XEvent *ev; ! XPointer *client_data; { ! return(_Ximp_ProtoReceive (d, w, ev, client_data)); } Bool _Ximp_XimFilter_Destroy (d, w, ev, client_data) ! Display *d; ! Window w; ! XEvent *ev; ! XPointer *client_data; { ! return(_Ximp_ServerDestroy (d, w, ev, client_data)); } *** /tmp/d03498 Tue Mar 9 09:18:42 1993 --- mit/lib/X/Ximp/XimpMCT.c Tue Mar 9 09:18:39 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpMCT.c,v 1.5 92/04/14 13:29:33 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpMCT.c,v 1.6 92/10/19 19:25:12 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 68,78 **** #include "Xlcint.h" #include "Ximplc.h" ! extern int _Ximp_cstostring(); ! extern int _Ximp_cstoct(); int Ximp_mbstostring(mbstr, mbstr_len, string, string_len, unconv_num) unsigned char *mbstr; int mbstr_len; --- 68,171 ---- #include "Xlcint.h" #include "Ximplc.h" ! extern int _Xlc_cstostring(), _Xlc_cstoct(); ! extern int _XlcCheckESCSequence(), _XlcCheckCSISequence(); + #define STRING_CONV(xxxtocs, cstoxxx) \ + unsigned char buf[BUFSIZE]; \ + int to_length, buf_len, scan_len, tmp_len; \ + int ret = -1; \ + LCMethods methods = LC_METHODS(lcd); \ + State state; \ + \ + if (to_len) { \ + to_length = *to_len; \ + *to_len = 0; \ + } else \ + to_length = MAXINT; \ + if (unconv_num) \ + *unconv_num = 0; \ + \ + state = (*methods->create_state)(lcd); \ + (*methods->cnv_start)(state); \ + state->last_codeset = state->GL_codeset; \ + \ + while (from_len > 0 && to_length > 0) { \ + buf_len = BUFSIZE; \ + scan_len = (*xxxtocs)(state, from_ptr, from_len, buf, &buf_len); \ + if (scan_len == -1) \ + goto error; \ + if (scan_len == 0) \ + break; \ + \ + from_ptr += scan_len; \ + from_len -= scan_len; \ + \ + tmp_len = to_length; \ + if ((*cstoxxx)(state, buf, buf_len, to_ptr, &tmp_len) == -1) { \ + if (unconv_num) \ + *unconv_num += buf_len / state->codeset->length; \ + continue; \ + } \ + \ + if (to_ptr) \ + to_ptr += tmp_len; \ + if (to_len) \ + *to_len += tmp_len; \ + to_length -= tmp_len; \ + state->last_codeset = state->codeset; \ + } \ + \ + ret = from_ptr - from; \ + \ + error: \ + (*methods->cnv_end)(state); \ + (*methods->destroy_state)(state); \ + \ + return ret; + static int + strtostr(lcd, strtocs, from, from_len, cstostr, to, to_len, unconv_num) + XLCd lcd; + int (*strtocs)(); + unsigned char *from; + int from_len; + int (*cstostr)(); + unsigned char *to; + int *to_len; + int *unconv_num; + { + unsigned char *from_ptr = from; + unsigned char *to_ptr = to; + STRING_CONV(strtocs, cstostr) + } + int + _Xlc_strcpy(lcd, str1, str1_len, str2, str2_len, unconv_num) + XLCd lcd; + register unsigned char *str1; + register int str1_len; + register unsigned char *str2; + int *str2_len; + int *unconv_num; + { + unsigned char *str1_tmp = str1; + + if (str2_len && str1_len > *str2_len) + str1_len = *str2_len; + + while (str1_len--) + *str2++ = *str1++; + + if (unconv_num) + *unconv_num = 0; + if (str2_len) + *str2_len = str1 - str1_tmp; + + return str1 - str1_tmp; + } + + int Ximp_mbstostring(mbstr, mbstr_len, string, string_len, unconv_num) unsigned char *mbstr; int mbstr_len; *************** *** 80,98 **** int *string_len; int *unconv_num; { ! Ximp_XLCd lcd = (Ximp_XLCd) _XlcCurrentLC(); if (lcd == NULL) return -1; ! return _Ximp_strtostr(lcd, lcd->ximp_lcpart->methods->mbstocs, mbstr, ! mbstr_len, _Ximp_cstostring, string, string_len, ! unconv_num); } int _Ximp_mbstostring(lcd, mbstr, mbstr_len, string, string_len, unconv_num) ! Ximp_XLCd lcd; unsigned char *mbstr; int mbstr_len; unsigned char *string; --- 173,190 ---- int *string_len; int *unconv_num; { ! XLCd lcd = _XlcCurrentLC(); if (lcd == NULL) return -1; ! return _Ximp_mbstostring(lcd, mbstr, mbstr_len, string, string_len, ! unconv_num); } int _Ximp_mbstostring(lcd, mbstr, mbstr_len, string, string_len, unconv_num) ! XLCd lcd; unsigned char *mbstr; int mbstr_len; unsigned char *string; *************** *** 99,107 **** int *string_len; int *unconv_num; { ! return _Ximp_strtostr(lcd, lcd->ximp_lcpart->methods->mbstocs, mbstr, ! mbstr_len, _Ximp_cstostring, string, string_len, ! unconv_num); } --- 191,200 ---- int *string_len; int *unconv_num; { ! LCMethods methods = LC_METHODS(lcd); ! ! return strtostr(lcd, methods->mbstocs, mbstr, mbstr_len, _Xlc_cstostring, ! string, string_len, unconv_num); } *************** *** 113,131 **** int *ctext_len; int *unconv_num; { ! Ximp_XLCd lcd = (Ximp_XLCd) _XlcCurrentLC(); if (lcd == NULL) return -1; ! return _Ximp_strtostr(lcd, lcd->ximp_lcpart->methods->mbstocs, mbstr, ! mbstr_len, _Ximp_cstoct, ctext, ctext_len, ! unconv_num); } int _Ximp_mbstoct(lcd, mbstr, mbstr_len, ctext, ctext_len, unconv_num) ! Ximp_XLCd lcd; unsigned char *mbstr; int mbstr_len; unsigned char *ctext; --- 206,222 ---- int *ctext_len; int *unconv_num; { ! XLCd lcd = _XlcCurrentLC(); if (lcd == NULL) return -1; ! return _Ximp_mbstoct(lcd, mbstr, mbstr_len, ctext, ctext_len, unconv_num); } int _Ximp_mbstoct(lcd, mbstr, mbstr_len, ctext, ctext_len, unconv_num) ! XLCd lcd; unsigned char *mbstr; int mbstr_len; unsigned char *ctext; *************** *** 132,140 **** int *ctext_len; int *unconv_num; { ! return _Ximp_strtostr(lcd, lcd->ximp_lcpart->methods->mbstocs, mbstr, ! mbstr_len, _Ximp_cstoct, ctext, ctext_len, ! unconv_num); } --- 223,232 ---- int *ctext_len; int *unconv_num; { ! LCMethods methods = LC_METHODS(lcd); ! ! return strtostr(lcd, methods->mbstocs, mbstr, mbstr_len, _Xlc_cstoct, ! ctext, ctext_len, unconv_num); } *************** *** 146,152 **** int *mbstr_len; int *unconv_num; { ! Ximp_XLCd lcd = (Ximp_XLCd) _XlcCurrentLC(); if (lcd == NULL) return -1; --- 238,244 ---- int *mbstr_len; int *unconv_num; { ! XLCd lcd = _XlcCurrentLC(); if (lcd == NULL) return -1; *************** *** 156,162 **** int _Ximp_cttombs(lcd, ctext, ctext_len, mbstr, mbstr_len, unconv_num) ! Ximp_XLCd lcd; unsigned char *ctext; int ctext_len; unsigned char *mbstr; --- 248,254 ---- int _Ximp_cttombs(lcd, ctext, ctext_len, mbstr, mbstr_len, unconv_num) ! XLCd lcd; unsigned char *ctext; int ctext_len; unsigned char *mbstr; *************** *** 166,176 **** unsigned char ch, *ctptr = ctext; unsigned char *bufptr = mbstr; unsigned char *tmpptr; ! unsigned char msb_mask; ! int GL_codeset, GR_codeset, codeset_number; int buf_len, tmp_len, skip_size; int ret = -1; ! int (*cstombs)(); if (mbstr_len) buf_len = *mbstr_len; --- 258,270 ---- unsigned char ch, *ctptr = ctext; unsigned char *bufptr = mbstr; unsigned char *tmpptr; ! unsigned char side; int buf_len, tmp_len, skip_size; int ret = -1; ! LCMethods methods = LC_METHODS(lcd); ! State state; ! CharSet charset, GR_charset, GL_charset; ! CodeSet codeset; if (mbstr_len) buf_len = *mbstr_len; *************** *** 179,203 **** if (unconv_num) *unconv_num = 0; ! cstombs = lcd->ximp_lcpart->methods->cstombs; ! GL_codeset = _get_codeset_number(lcd, ISO8859_1, GL); ! GR_codeset = _get_codeset_number(lcd, ISO8859_1, GR); ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); while (ctext_len > 0 && buf_len > 0) { ch = *ctptr; ! if (ch == 0x1b) { ! tmp_len = _check_ESC_sequence(lcd, ctptr, ctext_len, ! &GL_codeset, &GR_codeset); ! } else if (ch == 0x9b) { ! tmp_len =_check_CSI_sequence(lcd, ctptr, ctext_len); } else { tmpptr = ctptr; ! msb_mask = ch & 0x80; for ( ; ctext_len; tmpptr++, ctext_len--) { ch = *tmpptr; ! if (msb_mask != (ch & 0x80) || ch == '\033' || ch == 0x9b) break; if ((ch < 0x20 && ch != '\n' && ch != '\t') || (ch >= 0x80 && ch < 0xa0)) --- 273,304 ---- if (unconv_num) *unconv_num = 0; ! GL_charset = _XlcGetCharSetFromName("ISO8859-1", GL); ! GR_charset = _XlcGetCharSetFromName("ISO8859-1", GR); ! state = (*methods->create_state)(lcd); ! (*methods->cnv_start)(state); while (ctext_len > 0 && buf_len > 0) { ch = *ctptr; ! if (ch == 0x1b || ch == 0x9b) { ! if (ch == 0x1b) ! tmp_len = _XlcCheckESCSequence(ctptr, ctext_len, &charset); ! else ! tmp_len = _XlcCheckCSISequence(ctptr, ctext_len, &charset); ! ! if (tmp_len > 0 && charset) { ! if (charset->side == GL) ! GL_charset = charset; ! else ! GR_charset = charset; ! } } else { tmpptr = ctptr; ! side = ch & 0x80; for ( ; ctext_len; tmpptr++, ctext_len--) { ch = *tmpptr; ! if (side != (ch & 0x80) || ch == '\033' || ch == 0x9b) break; if ((ch < 0x20 && ch != '\n' && ch != '\t') || (ch >= 0x80 && ch < 0xa0)) *************** *** 204,214 **** goto error; } ! codeset_number = msb_mask ? GR_codeset : GL_codeset; ! if (codeset_number > -1) { tmp_len = buf_len; ! skip_size = (*cstombs)(lcd, ctptr, tmpptr - ctptr, ! bufptr, &tmp_len, codeset_number); if (skip_size < 0 || skip_size != tmpptr - ctptr) goto error; --- 305,316 ---- goto error; } ! charset = side ? GR_charset : GL_charset; ! if (codeset = _XlcGetCodeSetFromCharSet(lcd, charset)) { ! state->codeset = codeset; tmp_len = buf_len; ! skip_size = (*methods->cstombs)(state, ctptr, tmpptr - ctptr, ! bufptr, &tmp_len); if (skip_size < 0 || skip_size != tmpptr - ctptr) goto error; *************** *** 228,234 **** *mbstr_len = bufptr - mbstr; ret = ctptr - ctext; error: ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); return ret; } --- 330,337 ---- *mbstr_len = bufptr - mbstr; ret = ctptr - ctext; error: ! (*methods->cnv_end)(state); ! (*methods->destroy_state)(state); return ret; } *************** *** 235,241 **** int _Ximp_ct_mbslen(lcd, ctext, ctext_len, unconv_num) ! Ximp_XLCd lcd; unsigned char *ctext; int ctext_len; int *unconv_num; --- 338,344 ---- int _Ximp_ct_mbslen(lcd, ctext, ctext_len, unconv_num) ! XLCd lcd; unsigned char *ctext; int ctext_len; int *unconv_num; *************** *** 242,276 **** { unsigned char ch, *ctptr = ctext; unsigned char *tmpptr; ! unsigned char msb_mask; unsigned char buf[BUFSIZE]; - int GL_codeset, GR_codeset, codeset_number; int tmp_len, skip_size; int ret = 0; ! int (*cstombs)(); if (unconv_num) *unconv_num = 0; ! cstombs = lcd->ximp_lcpart->methods->cstombs; ! GL_codeset = _get_codeset_number(lcd, ISO8859_1, GL); ! GR_codeset = _get_codeset_number(lcd, ISO8859_1, GR); ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); while (ctext_len > 0) { ch = *ctptr; ! if (ch == 0x1b) { ! tmp_len = _check_ESC_sequence(lcd, ctptr, ctext_len, ! &GL_codeset, &GR_codeset); ! } else if (ch == 0x9b) { ! tmp_len =_check_CSI_sequence(lcd, ctptr, ctext_len); } else { tmpptr = ctptr; ! msb_mask = ch & 0x80; for ( ; ctext_len; tmpptr++, ctext_len--) { ch = *tmpptr; ! if (msb_mask != (ch & 0x80) || ch == '\033' || ch == 0x9b) break; if ((ch < 0x20 && ch != '\n' && ch != '\t') || (ch >= 0x80 && ch < 0xa0)) { --- 345,388 ---- { unsigned char ch, *ctptr = ctext; unsigned char *tmpptr; ! unsigned char side; unsigned char buf[BUFSIZE]; int tmp_len, skip_size; int ret = 0; ! LCMethods methods = LC_METHODS(lcd); ! State state; ! CharSet charset, GR_charset, GL_charset; ! CodeSet codeset; if (unconv_num) *unconv_num = 0; ! GL_charset = _XlcGetCharSetFromName("ISO8859-1", GL); ! GR_charset = _XlcGetCharSetFromName("ISO8859-1", GR); ! state = (*methods->create_state)(lcd); ! (*methods->cnv_start)(state); while (ctext_len > 0) { ch = *ctptr; ! if (ch == 0x1b || ch == 0x9b) { ! if (ch == 0x1b) ! tmp_len = _XlcCheckESCSequence(ctptr, ctext_len, &charset); ! else ! tmp_len = _XlcCheckCSISequence(ctptr, ctext_len, &charset); ! ! if (tmp_len > 0 && charset) { ! if (charset->side == GL) ! GL_charset = charset; ! else ! GR_charset = charset; ! } } else { tmpptr = ctptr; ! side = ch & 0x80; for ( ; ctext_len; tmpptr++, ctext_len--) { ch = *tmpptr; ! if (side != (ch & 0x80) || ch == '\033' || ch == 0x9b) break; if ((ch < 0x20 && ch != '\n' && ch != '\t') || (ch >= 0x80 && ch < 0xa0)) { *************** *** 279,291 **** } } ! codeset_number = msb_mask ? GR_codeset : GL_codeset; ! if (codeset_number > -1) { tmp_len = BUFSIZE; ! skip_size = (*cstombs)(lcd, ctptr, tmpptr - ctptr, ! buf, &tmp_len, codeset_number); if (skip_size < 0) { ! ret - -1; goto error; } ret += tmp_len; --- 391,404 ---- } } ! charset = side ? GR_charset : GL_charset; ! if (codeset = _XlcGetCodeSetFromCharSet(lcd, charset)) { ! state->codeset = codeset; tmp_len = BUFSIZE; ! skip_size = (*methods->cstombs)(state, ctptr, tmpptr - ctptr, ! buf, &tmp_len); if (skip_size < 0) { ! ret = -1; goto error; } ret += tmp_len; *************** *** 302,308 **** ctext_len -= tmp_len; } error: ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); return ret; } --- 415,422 ---- ctext_len -= tmp_len; } error: ! (*methods->cnv_end)(state); ! (*methods->destroy_state)(state); return ret; } *** /tmp/d03520 Tue Mar 9 09:18:53 1993 --- mit/lib/X/Ximp/XimpMDrS.c Tue Mar 9 09:18:51 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpMDrS.c,v 1.3 92/04/14 13:29:36 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpMDrS.c,v 1.4 92/10/19 19:25:35 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *** /tmp/d03542 Tue Mar 9 09:19:05 1993 --- mit/lib/X/Ximp/XimpMEsc.c Tue Mar 9 09:19:02 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpMEsc.c,v 1.3 92/04/14 13:29:38 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpMEsc.c,v 1.4 92/10/19 19:25:41 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *** /tmp/d03564 Tue Mar 9 09:19:16 1993 --- mit/lib/X/Ximp/XimpMExt.c Tue Mar 9 09:19:13 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpMExt.c,v 1.3 92/04/14 13:29:40 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpMExt.c,v 1.4 92/10/19 19:25:45 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *** /tmp/d03586 Tue Mar 9 09:19:26 1993 --- mit/lib/X/Ximp/XimpWCT.c Tue Mar 9 09:19:24 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpWCT.c,v 1.5 92/04/14 13:30:14 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpWCT.c,v 1.6 92/10/19 19:26:38 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 68,78 **** #include "Xlcint.h" #include "Ximplc.h" ! extern int _Ximp_cstostring(); ! extern int _Ximp_cstoct(); int Ximp_wcstostring(wcstr, wcstr_len, string, string_len, unconv_num) wchar_t *wcstr; int wcstr_len; --- 68,198 ---- #include "Xlcint.h" #include "Ximplc.h" ! extern int _Xlc_cstostring(), _Xlc_cstoct(); ! extern int _XlcCheckESCSequence(), _XlcCheckCSISequence(); + #define STRING_CONV(xxxtocs, cstoxxx) \ + unsigned char buf[BUFSIZE]; \ + int to_length, buf_len, scan_len, tmp_len; \ + int ret = -1; \ + LCMethods methods = LC_METHODS(lcd); \ + State state; \ + \ + if (to_len) { \ + to_length = *to_len; \ + *to_len = 0; \ + } else \ + to_length = MAXINT; \ + if (unconv_num) \ + *unconv_num = 0; \ + \ + state = (*methods->create_state)(lcd); \ + (*methods->cnv_start)(state); \ + state->last_codeset = state->GL_codeset; \ + \ + while (from_len > 0 && to_length > 0) { \ + buf_len = BUFSIZE; \ + scan_len = (*xxxtocs)(state, from_ptr, from_len, buf, &buf_len); \ + if (scan_len == -1) \ + goto error; \ + if (scan_len == 0) \ + break; \ + \ + from_ptr += scan_len; \ + from_len -= scan_len; \ + \ + tmp_len = to_length; \ + if ((*cstoxxx)(state, buf, buf_len, to_ptr, &tmp_len) == -1) { \ + if (unconv_num) \ + *unconv_num += buf_len / state->codeset->length; \ + continue; \ + } \ + \ + if (to_ptr) \ + to_ptr += tmp_len; \ + if (to_len) \ + *to_len += tmp_len; \ + to_length -= tmp_len; \ + state->last_codeset = state->codeset; \ + } \ + \ + ret = from_ptr - from; \ + \ + error: \ + (*methods->cnv_end)(state); \ + (*methods->destroy_state)(state); \ + \ + return ret; + static int + strtowstr(lcd, strtocs, from, from_len, cstowstr, to, to_len, unconv_num) + XLCd lcd; + int (*strtocs)(); + unsigned char *from; + int from_len; + int (*cstowstr)(); + wchar_t *to; + int *to_len; + int *unconv_num; + { + unsigned char *from_ptr = from; + wchar_t *to_ptr = to; + STRING_CONV(strtocs, cstowstr) + } + + static int + wstrtostr(lcd, wstrtocs, from, from_len, cstostr, to, to_len, unconv_num) + XLCd lcd; + int (*wstrtocs)(); + wchar_t *from; + int from_len; + int (*cstostr)(); + unsigned char *to; + int *to_len; + int *unconv_num; + { + wchar_t *from_ptr = from; + unsigned char *to_ptr = to; + STRING_CONV(wstrtocs, cstostr) + } + int + _Xlc_mbstowcs(lcd, mbstr, mbstr_len, wcstr, wcstr_len, unconv_num) + XLCd lcd; + unsigned char *mbstr; + int mbstr_len; + wchar_t *wcstr; + int *wcstr_len; + int *unconv_num; + { + LCMethods methods = LC_METHODS(lcd); + + if (lcd == NULL && (lcd = _XlcCurrentLC()) == NULL) + return -1; + + return strtowstr(lcd, methods->mbstocs, mbstr, mbstr_len, methods->cstowcs, + wcstr, wcstr_len, unconv_num); + } + + int + _Xlc_wcstombs(lcd, wcstr, wcstr_len, mbstr, mbstr_len, unconv_num) + XLCd lcd; + wchar_t *wcstr; + int wcstr_len; + unsigned char *mbstr; + int *mbstr_len; + int *unconv_num; + { + LCMethods methods = LC_METHODS(lcd); + + if (lcd == NULL && (lcd = _XlcCurrentLC()) == NULL) + return -1; + + return wstrtostr(lcd, methods->wcstocs, wcstr, wcstr_len, methods->cstombs, + mbstr, mbstr_len, unconv_num); + } + + int Ximp_wcstostring(wcstr, wcstr_len, string, string_len, unconv_num) wchar_t *wcstr; int wcstr_len; *************** *** 80,98 **** int *string_len; int *unconv_num; { ! Ximp_XLCd lcd = (Ximp_XLCd) _XlcCurrentLC(); if (lcd == NULL) return -1; ! return _Ximp_wstrtostr(lcd, lcd->ximp_lcpart->methods->wcstocs, wcstr, ! wcstr_len, _Ximp_cstostring, string, string_len, ! unconv_num); } int _Ximp_wcstostring(lcd, wcstr, wcstr_len, string, string_len, unconv_num) ! Ximp_XLCd lcd; wchar_t *wcstr; int wcstr_len; unsigned char *string; --- 200,217 ---- int *string_len; int *unconv_num; { ! XLCd lcd = _XlcCurrentLC(); if (lcd == NULL) return -1; ! return _Ximp_wcstostring(lcd, wcstr, wcstr_len, string, string_len, ! unconv_num); } int _Ximp_wcstostring(lcd, wcstr, wcstr_len, string, string_len, unconv_num) ! XLCd lcd; wchar_t *wcstr; int wcstr_len; unsigned char *string; *************** *** 99,107 **** int *string_len; int *unconv_num; { ! return _Ximp_wstrtostr(lcd, lcd->ximp_lcpart->methods->wcstocs, wcstr, ! wcstr_len, _Ximp_cstostring, string, string_len, ! unconv_num); } --- 218,227 ---- int *string_len; int *unconv_num; { ! LCMethods methods = LC_METHODS(lcd); ! ! return wstrtostr(lcd, methods->wcstocs, wcstr, wcstr_len, _Xlc_cstostring, ! string, string_len, unconv_num); } *************** *** 113,131 **** int *ctext_len; int *unconv_num; { ! Ximp_XLCd lcd = (Ximp_XLCd) _XlcCurrentLC(); if (lcd == NULL) return -1; ! return _Ximp_wstrtostr(lcd, lcd->ximp_lcpart->methods->wcstocs, wcstr, ! wcstr_len, _Ximp_cstoct, ctext, ctext_len, ! unconv_num); } int _Ximp_wcstoct(lcd, wcstr, wcstr_len, ctext, ctext_len, unconv_num) ! Ximp_XLCd lcd; wchar_t *wcstr; int wcstr_len; unsigned char *ctext; --- 233,249 ---- int *ctext_len; int *unconv_num; { ! XLCd lcd = _XlcCurrentLC(); if (lcd == NULL) return -1; ! return _Ximp_wcstoct(lcd, wcstr, wcstr_len, ctext, ctext_len, unconv_num); } int _Ximp_wcstoct(lcd, wcstr, wcstr_len, ctext, ctext_len, unconv_num) ! XLCd lcd; wchar_t *wcstr; int wcstr_len; unsigned char *ctext; *************** *** 132,140 **** int *ctext_len; int *unconv_num; { ! return _Ximp_wstrtostr(lcd, lcd->ximp_lcpart->methods->wcstocs, wcstr, ! wcstr_len, _Ximp_cstoct, ctext, ctext_len, ! unconv_num); } --- 250,259 ---- int *ctext_len; int *unconv_num; { ! LCMethods methods = LC_METHODS(lcd); ! ! return wstrtostr(lcd, methods->wcstocs, wcstr, wcstr_len, _Xlc_cstoct, ! ctext, ctext_len, unconv_num); } *************** *** 146,152 **** int *wcstr_len; int *unconv_num; { ! Ximp_XLCd lcd = (Ximp_XLCd) _XlcCurrentLC(); if (lcd == NULL) return -1; --- 265,271 ---- int *wcstr_len; int *unconv_num; { ! XLCd lcd = _XlcCurrentLC(); if (lcd == NULL) return -1; *************** *** 156,162 **** int _Ximp_cttowcs(lcd, ctext, ctext_len, wcstr, wcstr_len, unconv_num) ! Ximp_XLCd lcd; unsigned char *ctext; int ctext_len; wchar_t *wcstr; --- 275,281 ---- int _Ximp_cttowcs(lcd, ctext, ctext_len, wcstr, wcstr_len, unconv_num) ! XLCd lcd; unsigned char *ctext; int ctext_len; wchar_t *wcstr; *************** *** 166,176 **** unsigned char ch, *ctptr = ctext; wchar_t *bufptr = wcstr; unsigned char *tmpptr; ! unsigned char msb_mask; ! int GL_codeset, GR_codeset, codeset_number; int buf_len, tmp_len, skip_size; int ret = -1; ! int (*cstowcs)(); if (wcstr_len) buf_len = *wcstr_len; --- 285,297 ---- unsigned char ch, *ctptr = ctext; wchar_t *bufptr = wcstr; unsigned char *tmpptr; ! unsigned char side; int buf_len, tmp_len, skip_size; int ret = -1; ! LCMethods methods = LC_METHODS(lcd); ! State state; ! CharSet charset, GR_charset, GL_charset; ! CodeSet codeset; if (wcstr_len) buf_len = *wcstr_len; *************** *** 179,203 **** if (unconv_num) *unconv_num = 0; ! cstowcs = lcd->ximp_lcpart->methods->cstowcs; ! GL_codeset = _get_codeset_number(lcd, ISO8859_1, GL); ! GR_codeset = _get_codeset_number(lcd, ISO8859_1, GR); ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); while (ctext_len > 0 && buf_len > 0) { ch = *ctptr; ! if (ch == 0x1b) { ! tmp_len = _check_ESC_sequence(lcd, ctptr, ctext_len, ! &GL_codeset, &GR_codeset); ! } else if (ch == 0x9b) { ! tmp_len =_check_CSI_sequence(lcd, ctptr, ctext_len); } else { tmpptr = ctptr; ! msb_mask = ch & 0x80; for ( ; ctext_len; tmpptr++, ctext_len--) { ch = *tmpptr; ! if (msb_mask != (ch & 0x80) || ch == '\033' || ch == 0x9b) break; if ((ch < 0x20 && ch != '\n' && ch != '\t') || (ch >= 0x80 && ch < 0xa0)) --- 300,331 ---- if (unconv_num) *unconv_num = 0; ! GL_charset = _XlcGetCharSetFromName("ISO8859-1", GL); ! GR_charset = _XlcGetCharSetFromName("ISO8859-1", GR); ! state = (*methods->create_state)(lcd); ! (*methods->cnv_start)(state); while (ctext_len > 0 && buf_len > 0) { ch = *ctptr; ! if (ch == 0x1b || ch == 0x9b) { ! if (ch == 0x1b) ! tmp_len = _XlcCheckESCSequence(ctptr, ctext_len, &charset); ! else ! tmp_len = _XlcCheckCSISequence(ctptr, ctext_len, &charset); ! ! if (tmp_len > 0 && charset) { ! if (charset->side == GL) ! GL_charset = charset; ! else ! GR_charset = charset; ! } } else { tmpptr = ctptr; ! side = ch & 0x80; for ( ; ctext_len; tmpptr++, ctext_len--) { ch = *tmpptr; ! if (side != (ch & 0x80) || ch == '\033' || ch == 0x9b) break; if ((ch < 0x20 && ch != '\n' && ch != '\t') || (ch >= 0x80 && ch < 0xa0)) *************** *** 204,214 **** goto error; } ! codeset_number = msb_mask ? GR_codeset : GL_codeset; ! if (codeset_number > -1) { tmp_len = buf_len; ! skip_size = (*cstowcs)(lcd, ctptr, tmpptr - ctptr, ! bufptr, &tmp_len, codeset_number); if (skip_size < 0 || skip_size != tmpptr - ctptr) goto error; --- 332,343 ---- goto error; } ! charset = side ? GR_charset : GL_charset; ! if (codeset = _XlcGetCodeSetFromCharSet(lcd, charset)) { ! state->codeset = codeset; tmp_len = buf_len; ! skip_size = (*methods->cstowcs)(state, ctptr, tmpptr - ctptr, ! bufptr, &tmp_len); if (skip_size < 0 || skip_size != tmpptr - ctptr) goto error; *************** *** 228,234 **** *wcstr_len = bufptr - wcstr; ret = ctptr - ctext; error: ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); return ret; } --- 357,364 ---- *wcstr_len = bufptr - wcstr; ret = ctptr - ctext; error: ! (*methods->cnv_end)(state); ! (*methods->destroy_state)(state); return ret; } *************** *** 235,241 **** int _Ximp_ct_wcslen(lcd, ctext, ctext_len, unconv_num) ! Ximp_XLCd lcd; unsigned char *ctext; int ctext_len; int *unconv_num; --- 365,371 ---- int _Ximp_ct_wcslen(lcd, ctext, ctext_len, unconv_num) ! XLCd lcd; unsigned char *ctext; int ctext_len; int *unconv_num; *************** *** 242,276 **** { unsigned char ch, *ctptr = ctext; unsigned char *tmpptr; ! unsigned char msb_mask; wchar_t buf[BUFSIZE]; - int GL_codeset, GR_codeset, codeset_number; int tmp_len, skip_size; int ret = 0; ! int (*cstowcs)(); if (unconv_num) *unconv_num = 0; ! cstowcs = lcd->ximp_lcpart->methods->cstowcs; ! GL_codeset = _get_codeset_number(lcd, ISO8859_1, GL); ! GR_codeset = _get_codeset_number(lcd, ISO8859_1, GR); ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); while (ctext_len > 0) { ch = *ctptr; ! if (ch == 0x1b) { ! tmp_len = _check_ESC_sequence(lcd, ctptr, ctext_len, ! &GL_codeset, &GR_codeset); ! } else if (ch == 0x9b) { ! tmp_len =_check_CSI_sequence(lcd, ctptr, ctext_len); } else { tmpptr = ctptr; ! msb_mask = ch & 0x80; for ( ; ctext_len; tmpptr++, ctext_len--) { ch = *tmpptr; ! if (msb_mask != (ch & 0x80) || ch == '\033' || ch == 0x9b) break; if ((ch < 0x20 && ch != '\n' && ch != '\t') || (ch >= 0x80 && ch < 0xa0)) { --- 372,415 ---- { unsigned char ch, *ctptr = ctext; unsigned char *tmpptr; ! unsigned char side; wchar_t buf[BUFSIZE]; int tmp_len, skip_size; int ret = 0; ! LCMethods methods = LC_METHODS(lcd); ! State state; ! CharSet charset, GR_charset, GL_charset; ! CodeSet codeset; if (unconv_num) *unconv_num = 0; ! GL_charset = _XlcGetCharSetFromName("ISO8859-1", GL); ! GR_charset = _XlcGetCharSetFromName("ISO8859-1", GR); ! state = (*methods->create_state)(lcd); ! (*methods->cnv_start)(state); while (ctext_len > 0) { ch = *ctptr; ! if (ch == 0x1b || ch == 0x9b) { ! if (ch == 0x1b) ! tmp_len = _XlcCheckESCSequence(ctptr, ctext_len, &charset); ! else ! tmp_len = _XlcCheckCSISequence(ctptr, ctext_len, &charset); ! ! if (tmp_len > 0 && charset) { ! if (charset->side == GL) ! GL_charset = charset; ! else ! GR_charset = charset; ! } } else { tmpptr = ctptr; ! side = ch & 0x80; for ( ; ctext_len; tmpptr++, ctext_len--) { ch = *tmpptr; ! if (side != (ch & 0x80) || ch == '\033' || ch == 0x9b) break; if ((ch < 0x20 && ch != '\n' && ch != '\t') || (ch >= 0x80 && ch < 0xa0)) { *************** *** 279,289 **** } } ! codeset_number = msb_mask ? GR_codeset : GL_codeset; ! if (codeset_number > -1) { tmp_len = BUFSIZE; ! skip_size = (*cstowcs)(lcd, ctptr, tmpptr - ctptr, ! buf, &tmp_len, codeset_number); if (skip_size < 0) { ret = -1; goto error; --- 418,429 ---- } } ! charset = side ? GR_charset : GL_charset; ! if (codeset = _XlcGetCodeSetFromCharSet(lcd, charset)) { ! state->codeset = codeset; tmp_len = BUFSIZE; ! skip_size = (*methods->cstowcs)(state, ctptr, tmpptr - ctptr, ! buf, &tmp_len); if (skip_size < 0) { ret = -1; goto error; *************** *** 302,308 **** ctext_len -= tmp_len; } error: ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); return ret; } --- 442,449 ---- ctext_len -= tmp_len; } error: ! (*methods->cnv_end)(state); ! (*methods->destroy_state)(state); return ret; } *** /tmp/d03608 Tue Mar 9 09:19:38 1993 --- mit/lib/X/Ximp/XimpWDrS.c Tue Mar 9 09:19:35 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpWDrS.c,v 1.3 92/04/14 13:30:18 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpWDrS.c,v 1.4 92/10/19 19:26:42 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *** /tmp/d03630 Tue Mar 9 09:19:49 1993 --- mit/lib/X/Ximp/XimpWEsc.c Tue Mar 9 09:19:46 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpWEsc.c,v 1.3 92/04/14 13:30:22 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpWEsc.c,v 1.4 92/10/19 19:26:46 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *** /tmp/d03652 Tue Mar 9 09:19:59 1993 --- mit/lib/X/Ximp/XimpWExt.c Tue Mar 9 09:19:57 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpWExt.c,v 1.3 92/04/14 13:30:24 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpWExt.c,v 1.4 92/10/19 19:26:49 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *** /tmp/d03674 Tue Mar 9 09:20:11 1993 --- mit/lib/X/Ximp/Ximplc.h Tue Mar 9 09:20:08 1993 *************** *** 1,4 **** ! /* $XConsortium: Ximplc.h,v 1.6 92/07/29 10:16:27 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: Ximplc.h,v 1.7 92/10/19 19:27:10 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 29,60 **** /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED ! Copyright 1991, 1992 by Sony Corporation Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear ! in supporting documentation, and that the name of FUJITSU LIMITED ! and Sony Corporation not be used in advertising or publicity ! pertaining to distribution of the software without specific, written ! prior permission. ! FUJITSU LIMITED and Sony Corporation make no representations about ! the suitability of this software for any purpose. It is provided ! "as is" without express or implied warranty. ! FUJITSU LIMITED AND SONY CORPORATION DISCLAIM ALL WARRANTIES WITH ! REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND ! SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL ! DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA ! OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ! TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ! PERFORMANCE ! OF THIS SOFTWARE. Author: Takashi Fujiwara FUJITSU LIMITED ! Makoto Wakamatsu Sony Corporation ******************************************************************/ /* --- 29,62 ---- /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED ! Copyright 1991, 1992 by Sun Microsystems, Inc. ! Copyright 1991, 1992 by Sony Corporaion Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear ! in supporting documentation, and that the name of FUJITSU LIMITED, ! Sun Microsystems, Inc. and Sony Corporation not be used in advertising ! or publicity pertaining to distribution of the software without specific, ! written prior permission. ! FUJITSU LIMITED, Sun Microsystems, Inc. and Sony Corporation make no ! representations about the suitability of this software for any purpose. ! It is provided "as is" without express or implied warranty. ! FUJITSU LIMITED, SUN MICROSYSTEMS, INC. AND SONY CORPORATION DISCLAIM ! ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED ! WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU ! LIMITED, SUN MICROSYSTEMS, INC. AND SONY CORPORATION BE LIABLE FOR ANY ! SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ! RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF ! CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN ! CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Author: Takashi Fujiwara FUJITSU LIMITED ! Hiromu Inukai Sun Microsystems, Inc. ! Hideki Hiura Sun Microsystems, Inc. ! Makoto Wakamatsu Sony Corporaion ******************************************************************/ /* *************** *** 69,86 **** by Takashi Fujiwara,FUJITSU LIMITED. */ #include "XIMProto.h" ! #define USE_SJIS True ! #ifdef SVR4 ! #define FIX_EUC32 True #endif #define GL 0x00 #define GR 0x80 #define MAX_CODESET 10 #define MAX_FONTSET 50 ! #define XIMP_MB_CUR_MAX(lcd) (((Ximp_XLCd)(lcd))->ximp_lcpart->mb_cur_max) #ifndef MB_CUR_MAX #define MB_CUR_MAX XIMP_MB_CUR_MAX(_XlcCurrentLC()) #endif --- 71,94 ---- by Takashi Fujiwara,FUJITSU LIMITED. */ + #define XIMP_40 #include "XIMProto.h" ! #ifndef NOT_USE_SJIS ! #define USE_SJIS #endif + #ifndef NOT_XIMP_BC + #define XIMP_BC + #endif + #define CODESET_FILE "Codeset" + #define COMPOSE_FILE "Compose" + #define GL 0x00 #define GR 0x80 #define MAX_CODESET 10 #define MAX_FONTSET 50 ! #define XIMP_MB_CUR_MAX(lcd) (((XimpLCd)(lcd))->locale.mb_cur_max) #ifndef MB_CUR_MAX #define MB_CUR_MAX XIMP_MB_CUR_MAX(_XlcCurrentLC()) #endif *************** *** 89,142 **** #endif #ifndef MAXINT ! #define MAXINT (~(1 << (8 * sizeof(int)) - 1)) #endif /* !MAXINT */ ! typedef struct _Ximp_XLCd *Ximp_XLCd; ! typedef struct _Ximp_XFontSet *Ximp_XFontSet; /* * XLCd dependent data */ ! enum { ! ISO8859_1, ISO8859_2, ISO8859_3, ISO8859_4, ISO8859_7, ! ISO8859_6, ISO8859_8, ISO8859_5, ISO8859_9, JISX0201_1976_0, ! GB2312_1980_0, GB2312_1980_1, JISX0208_1983_0, JISX0208_1983_1, ! KSC5601_1987_0, KSC5601_1987_1 ! } encoding_define; ! typedef struct { ! int lindex; ! unsigned char msb_mask; ! } EncodingIndexRec; ! typedef struct { ! int lindex; ! char *charset_name; ! int char_length; ! char *GL_encoding; ! int GL_gc_size; ! char *GR_encoding; ! int GR_gc_size; ! } EncodingRec; ! typedef struct { ! int char_length; ! unsigned char msb_mask; ! int index_num; ! EncodingIndexRec *encoding_index; ! } CodeSetRec; ! typedef struct { ! int cset_number; ! char *font_name; ! unsigned char msb_mask; ! Bool ext_flag; ! } FontSetDataRec; ! typedef struct { ! Bool (*initialize)(); void (*cnv_start)(); void (*cnv_end)(); char (*mbchar)(); --- 97,182 ---- #endif #ifndef MAXINT ! #define MAXINT (~((unsigned int)1 << (8 * sizeof(int)) - 1)) #endif /* !MAXINT */ ! #define LC_METHODS(lcd) (((XimpLCd)(lcd))->lc_methods) /* * XLCd dependent data */ ! typedef unsigned char Side; ! typedef struct _ParseInfoRec *ParseInfo; ! typedef struct _XimpLCdRec *XimpLCd; ! typedef struct _CharSetRec { ! char *name; ! Side side; ! int length; ! char *encoding; /* Compound Text encoding */ ! int gc_num; /* num of graphic characters */ ! Bool string_encoding; ! } CharSetRec, *CharSet; ! typedef struct _CodeSetRec { ! int cs_num; ! Side side; ! int length; ! ParseInfo parse_info; ! unsigned long wc_encoding; ! int charset_num; ! CharSet *charset_list; ! } CodeSetRec, *CodeSet; ! typedef enum { ! E_GL, /* GL encoding */ ! E_GR, /* GR encoding */ ! E_SS, /* single shift */ ! E_LSL, /* locking shift left */ ! E_LSR, /* locking shift right */ ! E_LAST ! } EncodingType; ! typedef struct _ParseInfoRec { ! EncodingType type; ! char *encoding; ! CodeSet codeset; ! } ParseInfoRec; ! typedef enum { ! MBType, ! WCType ! } CvtType; ! ! typedef struct _CvtDataRec { ! CvtType type; ! int per_size; ! union { ! char *multi_byte; ! wchar_t *wide_char; ! XChar2b *xchar2b; ! } string; ! int length; ! int cvt_length; ! CodeSet codeset; ! } CvtDataRec, *CvtData; ! ! typedef struct _StateRec { ! XimpLCd lcd; ! int (*converter)(); ! CodeSet codeset; ! CodeSet GL_codeset; ! CodeSet GR_codeset; ! CodeSet last_codeset; ! struct _StateRec *next; ! Bool is_used; ! } StateRec, *State; ! ! typedef struct _LCMethodsRec { ! void (*destroy)(); ! State (*create_state)(); ! void (*destroy_state)(); void (*cnv_start)(); void (*cnv_end)(); char (*mbchar)(); *************** *** 144,168 **** int (*wcstocs)(); int (*cstombs)(); int (*cstowcs)(); ! } XLCdXimpMethods; ! typedef struct { ! char *codeset_name; int codeset_num; ! CodeSetRec *codeset; int mb_cur_max; Bool state_dependent; int fontset_data_num; ! FontSetDataRec *fontset_data; ! XLCdXimpMethods *methods; XPointer extension; ! } XLCdXimpRec; ! typedef struct _Ximp_XLCd { XLCdMethods methods; XLCdCoreRec core; ! XLCdXimpRec *ximp_lcpart; ! } Ximp_XLCdRec; /* * XFontSet dependent data --- 184,224 ---- int (*wcstocs)(); int (*cstombs)(); int (*cstowcs)(); ! } LCMethodsRec, *LCMethods; ! typedef struct _FontSetDataRec { ! char *font_name; ! Side side; ! int cs_num; ! } FontSetDataRec, *FontSetData; ! ! typedef struct _LocaleRec { ! char *name; ! char *language; ! char *territory; ! char *codeset; int codeset_num; ! CodeSet *codeset_list; int mb_cur_max; + unsigned char *mb_parse_table; + int mb_parse_list_num; + ParseInfo *mb_parse_list; + unsigned long wc_encode_mask; + unsigned long wc_shift_bits; Bool state_dependent; + CodeSet initial_state_GL; + CodeSet initial_state_GR; int fontset_data_num; ! FontSetData fontset_data; XPointer extension; ! } LocaleRec, *Locale; ! typedef struct _XimpLCdRec { XLCdMethods methods; XLCdCoreRec core; ! LCMethods lc_methods; ! LocaleRec locale; ! } XimpLCdRec; /* * XFontSet dependent data *************** *** 170,185 **** typedef struct { XFontStruct *font; ! unsigned char msb_mask; ! unsigned min_char; ! unsigned max_char; ! } ExtFontRec; ! ! typedef struct { ! XFontStruct *font; ! unsigned char msb_mask; ! int ext_font_num; ! ExtFontRec *ext_font_list; } FontSetRec; typedef struct { --- 226,233 ---- typedef struct { XFontStruct *font; ! CodeSet codeset; ! Side side; } FontSetRec; typedef struct { *************** *** 188,201 **** XPointer extension; } XFontSetXimpRec; ! typedef struct _Ximp_XFontSet { XFontSetMethods methods; XFontSetCoreRec core; ! XFontSetXimpRec *ximp_fspart; ! } Ximp_XFontSetRec; ! extern EncodingRec **encoding_table; /* * Input Method data */ --- 236,264 ---- XPointer extension; } XFontSetXimpRec; ! typedef struct _XimpFontSetRec { XFontSetMethods methods; XFontSetCoreRec core; ! XFontSetXimpRec ximp_fspart; ! } XimpFontSetRec, *XimpFontSet; ! extern Bool _XlcRegisterCharSet(); ! extern CharSet _XlcGetCharSetFromEncoding(), _XlcGetCharSetFromName(); ! extern CodeSet _XlcGetCodeSetFromCharSet(); ! extern Bool _XlcInsertLoader(); + extern XimpLCd _XlcCreateLC(); + extern Bool _XlcLoadCodeSet(); + extern void _XlcDestroyLC(), _XlcDestroyState(), _XlcCnvStart(), _XlcCnvEnd(); + extern State _XlcCreateState(); + + extern char _Xlc_mbchar(); + extern int _Xlc_mbstocs(), _Xlc_wcstocs(), _Xlc_cstombs(), _Xlc_cstowcs(); + + extern XFontSet _XDefaultCreateFontSet(); + extern XIM _Ximp_OpenIM(); + + /* * Input Method data */ *************** *** 204,249 **** typedef struct _Ximp_XIC *Ximp_XIC; #define XIMP_NAME 256 - #define XIMP_TIME_OUT 120 #define XIMP_CREATE_IC 0 #define XIMP_SET_IC 1 #define XIMP_START_IC 2 ! #define XIMP_INPUT_STYLE 0x0001 ! #define XIMP_CLIENT_WIN 0x0002 ! #define XIMP_RES_NAME 0x0004 ! #define XIMP_RES_CLASS 0x0008 ! #define XIMP_GEOMETRY_CB 0x0010 ! #define XIMP_FILTER_EV 0x0020 ! #define XIMP_PRE_CALLBAK 0x0040 ! #define XIMP_STS_CALLBAK 0x0080 ! #define XIMP_PROP_FOCUS ( XIMP_FOCUS_WIN_MASK ) ! #define XIMP_PROP_PREEDIT ( XIMP_PRE_AREA_MASK \ ! | XIMP_PRE_FG_MASK \ ! | XIMP_PRE_BG_MASK \ ! | XIMP_PRE_COLORMAP_MASK \ ! | XIMP_PRE_BGPIXMAP_MASK \ ! | XIMP_PRE_LINESP_MASK \ ! | XIMP_PRE_CURSOR_MASK \ ! | XIMP_PRE_AREANEED_MASK \ ! | XIMP_PRE_SPOTL_MASK ) ! #define XIMP_PROP_STATUS ( XIMP_STS_AREA_MASK \ ! | XIMP_STS_FG_MASK \ ! | XIMP_STS_BG_MASK \ ! | XIMP_STS_COLORMAP_MASK \ ! | XIMP_STS_BGPIXMAP_MASK \ ! | XIMP_STS_LINESP_MASK \ ! | XIMP_STS_CURSOR_MASK \ ! | XIMP_STS_AREANEED_MASK \ ! | XIMP_STS_WINDOW_MASK ) ! #define XIMP_PROP_PREFONT ( XIMP_PRE_FONT_MASK ) ! #define XIMP_PROP_STSFONT ( XIMP_STS_FONT_MASK ) /* * XIM Extension data */ typedef struct { int extension_back_front_exist; Atom extension_back_front_id; --- 267,287 ---- typedef struct _Ximp_XIC *Ximp_XIC; #define XIMP_NAME 256 #define XIMP_CREATE_IC 0 #define XIMP_SET_IC 1 #define XIMP_START_IC 2 ! #define FILTERD True ! #define NOTFILTERD False ! #define XIMP_MAXBUF 1024 ! #define CT_MAX_IN_CM 15 /* * XIM Extension data */ + typedef struct { int extension_back_front_exist; Atom extension_back_front_id; *************** *** 260,277 **** Atom extension_lookup_proc; Atom extension_lookup_proc_rep; /* Add Extension */ ! } Ximp_ExtXIMRec; /* * XIM dependent data */ typedef struct { ! XIM im_next; ! int connectserver; ! int inputserver; ! Bool use_wchar; Ximp_KeyList *process_start_keys; ! char *locale_server; Window fe_window; Window owner; Atom improtocol_id; --- 298,368 ---- Atom extension_lookup_proc; Atom extension_lookup_proc_rep; /* Add Extension */ ! } Ximp_ExtXIMRec; /* + * Data dtructure for local processing + */ + + /* + * Method for represent Keysequence by Tree of DefTree structure. + * + * Key[:string] ->next + * | + * V succession + * + * : "A_diaerasis" + * : "A_acute" + * : "A_acute" + * + * is translated to + * + * Compose ----> acute -> NIL + * | | + * | V + * V A:A_acute + * A -> NIL | + * | V + * | NIL + * V + * quotedbl:A_diaerasis -> apostrophe:A_acute -> NIL + * | | + * V V + * NIL NIL + * + * Each structure address means context + * + */ + + typedef struct _DefTree { + struct _DefTree *next; /* another Key definition */ + struct _DefTree *succession; /* successive Key Sequence */ + /* Key definitions */ + unsigned modifier_mask; + unsigned modifier; + KeySym keysym; /* leaf only */ + char *mb; + wchar_t *wc; /* make from mb */ + #ifdef notdef + KeySym keysym_return; + #endif + } DefTree; + + /* * XIM dependent data */ + typedef struct { ! Bool is_local; ! int reconnection_mode; ! Bool is_connected; ! char *im_name; ! int def_svr_mode; Ximp_KeyList *process_start_keys; ! Bool use_wchar; ! XIMStyles *delaybind_styles; ! ! /* for IMServer */ Window fe_window; Window owner; Atom improtocol_id; *************** *** 289,324 **** Atom preeditfont_id; Atom statusfont_id; Atom preeditmaxsize_id; char *im_proto_vl; XIMStyles *im_styles; Ximp_KeyList *im_keyslist; char *im_server_name; char *im_server_vl; char *im_vendor_name; Atom *im_ext_list; Ximp_ExtXIMRec *imtype; - } XIMXimpRec; /* * IM struct */ typedef struct _Ximp_XIM { XIMMethods methods; XIMCoreRec core; XIMXimpRec *ximp_impart; ! } Ximp_XIMRec; typedef struct { XIMCallback start; XIMCallback done; XIMCallback draw; XIMCallback proc; ! } ICExtLookupCallbacks; /* * data block describing the visual attributes associated with an input * context */ typedef struct { XRectangle area; XRectangle area_needed; --- 380,437 ---- Atom preeditfont_id; Atom statusfont_id; Atom preeditmaxsize_id; + Atom type_id; + long *type_list; char *im_proto_vl; + int im_proto_vnum; XIMStyles *im_styles; Ximp_KeyList *im_keyslist; + Ximp_KeyList *im_offkeyslist; char *im_server_name; char *im_server_vl; char *im_vendor_name; Atom *im_ext_list; + + /* for Local Processing */ + XIC current_ic; + DefTree *top; + #ifdef BACKTRACK_WHEN_UNMATCHED + int num_save_rooms; + #endif + + /* for Extension */ Ximp_ExtXIMRec *imtype; + /* for Force Select KeyRelease */ + Bool is_forceselectkeyrelease; + } XIMXimpRec; + /* * IM struct */ + typedef struct _Ximp_XIM { XIMMethods methods; XIMCoreRec core; XIMXimpRec *ximp_impart; ! } Ximp_XIMRec; + /* + * Externsion Lookup Callback + */ + typedef struct { XIMCallback start; XIMCallback done; XIMCallback draw; XIMCallback proc; ! } ICExtLookupCallbacks; /* * data block describing the visual attributes associated with an input * context */ + typedef struct { XRectangle area; XRectangle area_needed; *************** *** 333,357 **** Cursor cursor; XPointer draw_data; ICExtLookupCallbacks callbacks; ! } ICExtLookupAttributes, *ICExtLookupAttributesPtr; /* * IC deprndent data */ typedef struct { long icid; ! int input_mode; ! int is_bep_mode; int filter_mode; - unsigned long back_mask; long value_mask; Bool putback_key_event; Window back_focus_win; ! long proto_mask; ! Ximp_PreeditPropRec preedit_attr; char *preedit_font; ! Ximp_StatusPropRec status_attr; char *status_font; XIMCallback error; /* Extended Callback attribute */ --- 446,483 ---- Cursor cursor; XPointer draw_data; ICExtLookupCallbacks callbacks; ! } ICExtLookupAttributes, *ICExtLookupAttributesPtr; + typedef int Ximp_CBStatus; + + #define XIMPCBPREEDITACTIVE 0x00000001 + #define XIMPCBSTATUSACTIVE 0x00000002 + #define DEFAULTCBSTATUSSTRING "Disconnected" + + typedef enum _Ximp_inputmode { + BEING_BYPASSED = 0, + BEING_PREEDITED = 1 + } input_mode_t ; + /* * IC deprndent data */ + typedef struct { long icid; ! int svr_mode; ! input_mode_t input_mode; int filter_mode; long value_mask; + unsigned long back_mask; Bool putback_key_event; Window back_focus_win; ! long proto3_mask; ! long proto4_mask; ! Ximp_PreeditPropRec4 preedit_attr; char *preedit_font; ! Ximp_StatusPropRec4 status_attr; char *status_font; XIMCallback error; /* Extended Callback attribute */ *************** *** 360,380 **** XIMCallback restart; XIMCallback destroy; void *ictype; ! } XICXimpRec; /* * IC struct */ typedef struct _Ximp_XIC { XICMethods methods; XICCoreRec core; XICXimpRec *ximp_icpart; ! } Ximp_XICRec; /* * predicate argument */ typedef struct { Atom type; Window owner; --- 486,517 ---- XIMCallback restart; XIMCallback destroy; + Ximp_CBStatus cbstatus ; + /* for Local Processing */ + DefTree *context; + DefTree *composed; + #ifdef BACKTRACK_WHEN_UNMATCHED + XEvent *saved_event; + int num_saved; + #endif + void *ictype; ! } XICXimpRec; /* * IC struct */ + typedef struct _Ximp_XIC { XICMethods methods; XICCoreRec core; XICXimpRec *ximp_icpart; ! } Ximp_XICRec; /* * predicate argument */ + typedef struct { Atom type; Window owner; *************** *** 389,391 **** --- 526,906 ---- Window window; Atom atom; } XimpPNPredicateArgRec, *XimpPNPredicateArg; + + typedef struct { + int proto3; + int proto4; + } XimpChangeMaskRec, *XimpChangeaMask; + + #define XIMP_INPUT_STYLE 0x0001 + #define XIMP_CLIENT_WIN 0x0002 + #define XIMP_RES_NAME 0x0004 + #define XIMP_RES_CLASS 0x0008 + #define XIMP_GEOMETRY_CB 0x0010 + #define XIMP_FILTER_EV 0x0020 + #define XIMP_PRE_CALLBAK 0x0040 + #define XIMP_STS_CALLBAK 0x0080 + + #define XIMP_CHK_FOCUSWINMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_FOCUS_WIN_MASK4) + #define XIMP_CHK_PREAREAMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_AREA_MASK4) + #define XIMP_CHK_PREAREANEEDMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_AREANEED_MASK4) + #define XIMP_CHK_PRECOLORMAPMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_COLORMAP_MASK4) + #define XIMP_CHK_PRESTDCOLORMAPMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_STD_COLORMAP_MASK4) + #define XIMP_CHK_PREFGMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_FG_MASK4) + #define XIMP_CHK_PREBGMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_BG_MASK4) + #define XIMP_CHK_PREBGPIXMAPMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_BGPIXMAP_MASK4) + #define XIMP_CHK_PRELINESPMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_LINESP_MASK4) + #define XIMP_CHK_PRECURSORMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_CURSOR_MASK4) + #define XIMP_CHK_PRESPOTLMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_SPOTL_MASK4) + #define XIMP_CHK_STSAREAMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_AREA_MASK4) + #define XIMP_CHK_STSAREANEEDMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_AREANEED_MASK4) + #define XIMP_CHK_STSCOLORMAPMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_COLORMAP_MASK4) + #define XIMP_CHK_STSSTDCOLORMAPMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_STD_COLORMAP_MASK4) + #define XIMP_CHK_STSFGMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_FG_MASK4) + #define XIMP_CHK_STSBGMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_BG_MASK4) + #define XIMP_CHK_STSBGPIXMAPMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_BGPIXMAP_MASK4) + #define XIMP_CHK_STSLINESPMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_LINESP_MASK4) + #define XIMP_CHK_STSCURSORMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_CURSOR_MASK4) + #define XIMP_CHK_STSWINDOWMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_WINDOW_MASK4) + #define XIMP_CHK_PREFONTMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_PRE_FONT_MASK4) + #define XIMP_CHK_STSFONTMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_STS_FONT_MASK4) + #define XIMP_CHK_SERVERTYPEMASK(ic) (ic->ximp_icpart->proto4_mask & XIMP_SERVERTYPE_MASK4) + + #define XIMP_CHK_PROP_FOCUS(mask) ( (mask.proto4) & XIMP_FOCUS_WIN_MASK4 ) + #define XIMP_CHK_PROP_PREEDIT(mask) ( (mask.proto4) & \ + ( XIMP_PRE_AREA_MASK4 \ + | XIMP_PRE_AREANEED_MASK4 \ + | XIMP_PRE_COLORMAP_MASK4 \ + | XIMP_PRE_STD_COLORMAP_MASK4 \ + | XIMP_PRE_FG_MASK4 \ + | XIMP_PRE_BG_MASK4 \ + | XIMP_PRE_BGPIXMAP_MASK4 \ + | XIMP_PRE_LINESP_MASK4 \ + | XIMP_PRE_CURSOR_MASK4 \ + | XIMP_PRE_SPOTL_MASK4 ) ) + #define XIMP_CHK_PROP_STATUS(mask) ( (mask.proto4) & \ + ( XIMP_STS_AREA_MASK4 \ + | XIMP_STS_AREANEED_MASK4 \ + | XIMP_STS_COLORMAP_MASK4 \ + | XIMP_STS_STD_COLORMAP_MASK4 \ + | XIMP_STS_FG_MASK4 \ + | XIMP_STS_BG_MASK4 \ + | XIMP_STS_BGPIXMAP_MASK4 \ + | XIMP_STS_LINESP_MASK4 \ + | XIMP_STS_CURSOR_MASK4 \ + | XIMP_STS_WINDOW_MASK4 ) ) + #define XIMP_CHK_PROP_PREFONT(mask) ( (mask.proto4) & XIMP_PRE_FONT_MASK4 ) + #define XIMP_CHK_PROP_STSFONT(mask) ( (mask.proto4) & XIMP_STS_FONT_MASK4 ) + #define XIMP_EQU_PRESPOTLMASK(mask) ( (mask.proto4) == XIMP_PRE_SPOTL_MASK4 ) + + #define XIMP_UNSET_PROPFOCUS(mask) { mask.proto4 &= ~(XIMP_FOCUS_WIN_MASK4); \ + mask.proto3 &= ~(XIMP_FOCUS_WIN_MASK3); } + #define XIMP_UNSET_PROPPREEDIT(mask) { mask.proto4 &= ~( \ + ( XIMP_PRE_AREA_MASK4 \ + | XIMP_PRE_AREANEED_MASK4 \ + | XIMP_PRE_COLORMAP_MASK4 \ + | XIMP_PRE_STD_COLORMAP_MASK4 \ + | XIMP_PRE_FG_MASK4 \ + | XIMP_PRE_BG_MASK4 \ + | XIMP_PRE_BGPIXMAP_MASK4 \ + | XIMP_PRE_LINESP_MASK4 \ + | XIMP_PRE_CURSOR_MASK4 \ + | XIMP_PRE_SPOTL_MASK4 \ + | XIMP_PRE_FONT_MASK4 ) ); \ + mask.proto3 &= ~( \ + ( XIMP_PRE_AREA_MASK3 \ + | XIMP_PRE_AREANEED_MASK3 \ + | XIMP_PRE_COLORMAP_MASK3 \ + | XIMP_PRE_FG_MASK3 \ + | XIMP_PRE_BG_MASK3 \ + | XIMP_PRE_BGPIXMAP_MASK3 \ + | XIMP_PRE_LINESP_MASK3 \ + | XIMP_PRE_CURSOR_MASK3 \ + | XIMP_PRE_SPOTL_MASK3 \ + | XIMP_PRE_FONT_MASK4 ) ); } + #define XIMP_UNSET_PROPSTATUS(mask) { mask.proto4 &= ~( \ + ( XIMP_STS_AREA_MASK4 \ + | XIMP_STS_AREANEED_MASK4 \ + | XIMP_STS_COLORMAP_MASK4 \ + | XIMP_STS_STD_COLORMAP_MASK4 \ + | XIMP_STS_FG_MASK4 \ + | XIMP_STS_BG_MASK4 \ + | XIMP_STS_BGPIXMAP_MASK4 \ + | XIMP_STS_LINESP_MASK4 \ + | XIMP_STS_CURSOR_MASK4 \ + | XIMP_STS_WINDOW_MASK4 \ + | XIMP_STS_FONT_MASK4 ) ); \ + mask.proto3 &= ~( \ + ( XIMP_STS_AREA_MASK3 \ + | XIMP_STS_AREANEED_MASK3 \ + | XIMP_STS_COLORMAP_MASK3 \ + | XIMP_STS_FG_MASK3 \ + | XIMP_STS_BG_MASK3 \ + | XIMP_STS_BGPIXMAP_MASK3 \ + | XIMP_STS_LINESP_MASK3 \ + | XIMP_STS_CURSOR_MASK3 \ + | XIMP_STS_WINDOW_MASK3 \ + | XIMP_STS_FONT_MASK3 ) ); } + + #define XIMP_SET_NULLMASK(mask) { mask.proto4 = NULL; \ + mask.proto3 = NULL; } + #define XIMP_SET_NULLMASK2(mask) { mask->proto4 = NULL; \ + mask->proto3 = NULL; } + + #define XIMP_SET_FOCUSWINMASK(ic) { ic->ximp_icpart->proto4_mask |= XIMP_FOCUS_WIN_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_FOCUS_WIN_MASK3; } + + #define XIMP_SET_FOCUSWINMASK2(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_FOCUS_WIN_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_FOCUS_WIN_MASK3; \ + mask->proto4 |= XIMP_FOCUS_WIN_MASK4; \ + mask->proto3 |= XIMP_FOCUS_WIN_MASK3; } + #define XIMP_SET_PREAREAMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_AREA_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_AREA_MASK3; \ + mask->proto4 |= XIMP_PRE_AREA_MASK4; \ + mask->proto3 |= XIMP_PRE_AREA_MASK3; } + #define XIMP_SET_PREAREANEEDMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_AREANEED_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_AREANEED_MASK3; \ + mask->proto4 |= XIMP_PRE_AREANEED_MASK4; \ + mask->proto3 |= XIMP_PRE_AREANEED_MASK3; } + #define XIMP_SET_PRECOLORMAPMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_COLORMAP_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_COLORMAP_MASK3; \ + mask->proto4 |= XIMP_PRE_COLORMAP_MASK4; \ + mask->proto3 |= XIMP_PRE_COLORMAP_MASK3; } + #define XIMP_SET_PRESTDCOLORMAPMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_STD_COLORMAP_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_COLORMAP_MASK3; \ + mask->proto4 |= XIMP_PRE_STD_COLORMAP_MASK4; \ + mask->proto3 |= XIMP_PRE_COLORMAP_MASK3; } + #define XIMP_SET_PREFGMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_FG_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_FG_MASK3; \ + mask->proto4 |= XIMP_PRE_FG_MASK4; \ + mask->proto3 |= XIMP_PRE_FG_MASK3; } + #define XIMP_SET_PREBGMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_BG_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_BG_MASK3; \ + mask->proto4 |= XIMP_PRE_BG_MASK4; \ + mask->proto3 |= XIMP_PRE_BG_MASK3; } + #define XIMP_SET_PREBGPIXMAPMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_BGPIXMAP_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_BGPIXMAP_MASK3; \ + mask->proto4 |= XIMP_PRE_BGPIXMAP_MASK4; \ + mask->proto3 |= XIMP_PRE_BGPIXMAP_MASK3; } + #define XIMP_SET_PRELINESPMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_LINESP_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_LINESP_MASK3; \ + mask->proto4 |= XIMP_PRE_LINESP_MASK4; \ + mask->proto3 |= XIMP_PRE_LINESP_MASK3; } + #define XIMP_SET_PRECURSORMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_CURSOR_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_CURSOR_MASK3; \ + mask->proto4 |= XIMP_PRE_CURSOR_MASK4; \ + mask->proto3 |= XIMP_PRE_CURSOR_MASK3; } + #define XIMP_SET_PRESPOTLMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_SPOTL_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_SPOTL_MASK3; \ + mask->proto4 |= XIMP_PRE_SPOTL_MASK4; \ + mask->proto3 |= XIMP_PRE_SPOTL_MASK3; } + + #define XIMP_SET_STSAREAMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_AREA_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_AREA_MASK3; \ + mask->proto4 |= XIMP_STS_AREA_MASK4; \ + mask->proto3 |= XIMP_STS_AREA_MASK3; } + #define XIMP_SET_STSAREANEEDMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_AREANEED_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_AREANEED_MASK3; \ + mask->proto4 |= XIMP_STS_AREANEED_MASK4; \ + mask->proto3 |= XIMP_STS_AREANEED_MASK3; } + #define XIMP_SET_STSCOLORMAPMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_COLORMAP_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_COLORMAP_MASK3; \ + mask->proto4 |= XIMP_STS_COLORMAP_MASK4; \ + mask->proto3 |= XIMP_STS_COLORMAP_MASK3; } + #define XIMP_SET_STSSTDCOLORMAPMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_STD_COLORMAP_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_COLORMAP_MASK3; \ + mask->proto4 |= XIMP_STS_STD_COLORMAP_MASK4; \ + mask->proto3 |= XIMP_STS_COLORMAP_MASK3; } + #define XIMP_SET_STSFGMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_FG_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_FG_MASK3; \ + mask->proto4 |= XIMP_STS_FG_MASK4; \ + mask->proto3 |= XIMP_STS_FG_MASK3; } + #define XIMP_SET_STSBGMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_BG_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_BG_MASK3; \ + mask->proto4 |= XIMP_STS_BG_MASK4; \ + mask->proto3 |= XIMP_STS_BG_MASK3; } + #define XIMP_SET_STSBGPIXMAPMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_BGPIXMAP_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_BGPIXMAP_MASK3; \ + mask->proto4 |= XIMP_STS_BGPIXMAP_MASK4; \ + mask->proto3 |= XIMP_STS_BGPIXMAP_MASK3; } + #define XIMP_SET_STSLINESPMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_LINESP_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_LINESP_MASK3; \ + mask->proto4 |= XIMP_STS_LINESP_MASK4; \ + mask->proto3 |= XIMP_STS_LINESP_MASK3; } + #define XIMP_SET_STSCURSORMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_CURSOR_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_CURSOR_MASK3; \ + mask->proto4 |= XIMP_STS_CURSOR_MASK4; \ + mask->proto3 |= XIMP_STS_CURSOR_MASK3; } + #define XIMP_SET_STSWINDOWMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_WINDOW_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_WINDOW_MASK3; \ + mask->proto4 |= XIMP_STS_WINDOW_MASK4; \ + mask->proto3 |= XIMP_STS_WINDOW_MASK3; } + + #define XIMP_SET_PREFONTMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_PRE_FONT_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_PRE_FONT_MASK3; \ + mask->proto4 |= XIMP_PRE_FONT_MASK4; \ + mask->proto3 |= XIMP_PRE_FONT_MASK3; } + #define XIMP_SET_STSFONTMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_STS_FONT_MASK4; \ + ic->ximp_icpart->proto3_mask |= XIMP_STS_FONT_MASK3; \ + mask->proto4 |= XIMP_STS_FONT_MASK4; \ + mask->proto3 |= XIMP_STS_FONT_MASK3; } + #define XIMP_SET_SERVERTYPEMASK(ic, mask) { ic->ximp_icpart->proto4_mask |= XIMP_SERVERTYPE_MASK4; \ + mask->proto4 |= XIMP_SERVERTYPE_MASK4; } + + #define XIMP_PROTO_MASK(ic, mask) (ISXimp4(ic)?mask.proto4:mask.proto3) + #define XIMP_PROTO_MASK2(ic) (ISXimp4(ic)?ic->ximp_icpart->proto4_mask:ic->ximp_icpart->proto3_mask) + + #define XIMP_FOCUS_WIN_MASK(ic) (ISXimp4(ic)?XIMP_FOCUS_WIN_MASK4:XIMP_FOCUS_WIN_MASK3) + #define XIMP_PRE_AREA_MASK(ic) (ISXimp4(ic)?XIMP_PRE_AREA_MASK4:XIMP_PRE_AREA_MASK3) + #define XIMP_PRE_AREANEED_MASK(ic) (ISXimp4(ic)?XIMP_PRE_AREANEED_MASK4:XIMP_PRE_AREANEED_MASK3) + #define XIMP_PRE_COLORMAP_MASK(ic) (ISXimp4(ic)?XIMP_PRE_COLORMAP_MASK4:XIMP_PRE_COLORMAP_MASK3) + #define XIMP_PRE_STD_COLORMAP_MASK(ic) (ISXimp4(ic)?XIMP_PRE_STD_COLORMAP_MASK4:XIMP_PRE_COLORMAP_MASK3) + #define XIMP_PRE_FG_MASK(ic) (ISXimp4(ic)?XIMP_PRE_FG_MASK4:XIMP_PRE_FG_MASK3) + #define XIMP_PRE_BG_MASK(ic) (ISXimp4(ic)?XIMP_PRE_BG_MASK4:XIMP_PRE_BG_MASK3) + #define XIMP_PRE_BGPIXMAP_MASK(ic) (ISXimp4(ic)?XIMP_PRE_BGPIXMAP_MASK4:XIMP_PRE_BGPIXMAP_MASK3) + #define XIMP_PRE_LINESP_MASK(ic) (ISXimp4(ic)?XIMP_PRE_LINESP_MASK4:XIMP_PRE_LINESP_MASK3) + #define XIMP_PRE_CURSOR_MASK(ic) (ISXimp4(ic)?XIMP_PRE_CURSOR_MASK4:XIMP_PRE_CURSOR_MASK3) + #define XIMP_PRE_SPOTL_MASK(ic) (ISXimp4(ic)?XIMP_PRE_SPOTL_MASK4:XIMP_PRE_SPOTL_MASK3) + #define XIMP_STS_AREA_MASK(ic) (ISXimp4(ic)?XIMP_STS_AREA_MASK4:XIMP_STS_AREA_MASK3) + #define XIMP_STS_AREANEED_MASK(ic) (ISXimp4(ic)?XIMP_STS_AREANEED_MASK4:XIMP_STS_AREANEED_MASK3) + #define XIMP_STS_COLORMAP_MASK(ic) (ISXimp4(ic)?XIMP_STS_COLORMAP_MASK4:XIMP_STS_COLORMAP_MASK3) + #define XIMP_STS_STD_COLORMAP_MASK(ic) (ISXimp4(ic)?XIMP_STS_STD_COLORMAP_MASK4:XIMP_STS_COLORMAP_MASK3) + #define XIMP_STS_FG_MASK(ic) (ISXimp4(ic)?XIMP_STS_FG_MASK4:XIMP_STS_FG_MASK3) + #define XIMP_STS_BG_MASK(ic) (ISXimp4(ic)?XIMP_STS_BG_MASK4:XIMP_STS_BG_MASK3) + #define XIMP_STS_BGPIXMAP_MASK(ic) (ISXimp4(ic)?XIMP_STS_BGPIXMAP_MASK4:XIMP_STS_BGPIXMAP_MASK3) + #define XIMP_STS_LINESP_MASK(ic) (ISXimp4(ic)?XIMP_STS_LINESP_MASK4:XIMP_STS_LINESP_MASK3) + #define XIMP_STS_CURSOR_MASK(ic) (ISXimp4(ic)?XIMP_STS_CURSOR_MASK4:XIMP_STS_CURSOR_MASK3) + #define XIMP_STS_WINDOW_MASK(ic) (ISXimp4(ic)?XIMP_STS_WINDOW_MASK4:XIMP_STS_WINDOW_MASK3) + #define XIMP_PRE_FONT_MASK(ic) (ISXimp4(ic)?XIMP_PRE_FONT_MASK4:XIMP_PRE_FONT_MASK3) + #define XIMP_STS_FONT_MASK(ic) (ISXimp4(ic)?XIMP_STS_FONT_MASK4:XIMP_STS_FONT_MASK3) + + #define XIMP_PROP_FOCUS(ic) ( XIMP_FOCUS_WIN_MASK(ic) ) + #define XIMP_PROP_PREEDIT(ic) ( XIMP_PRE_AREA_MASK(ic) \ + | XIMP_PRE_FG_MASK(ic) \ + | XIMP_PRE_BG_MASK(ic) \ + | XIMP_PRE_COLORMAP_MASK(ic) \ + | XIMP_PRE_BGPIXMAP_MASK(ic) \ + | XIMP_PRE_LINESP_MASK(ic) \ + | XIMP_PRE_CURSOR_MASK(ic) \ + | XIMP_PRE_AREANEED_MASK(ic) \ + | XIMP_PRE_SPOTL_MASK(ic) ) + #define XIMP_PROP_STATUS(ic) ( XIMP_STS_AREA_MASK(ic) \ + | XIMP_STS_FG_MASK(ic) \ + | XIMP_STS_BG_MASK(ic) \ + | XIMP_STS_COLORMAP_MASK(ic) \ + | XIMP_STS_BGPIXMAP_MASK(ic) \ + | XIMP_STS_LINESP_MASK(ic) \ + | XIMP_STS_CURSOR_MASK(ic) \ + | XIMP_STS_AREANEED_MASK(ic) \ + | XIMP_STS_WINDOW_MASK(ic) ) + #define XIMP_PROP_PREFONT(ic) ( XIMP_PRE_FONT_MASK(ic) ) + #define XIMP_PROP_STSFONT(ic) ( XIMP_STS_FONT_MASK(ic) ) + + #define XIMP_NOCONNECT 0x0000 + #define XIMP_DELAYBINDABLE 0x0001 + #define XIMP_RECONNECTABLE 0x0002 + #define XIMP_RESTARTABLE 0x0004 + + #define IS_FORCESELECTKEYRELEASE(im) (((Ximp_XIM)(im))->ximp_impart->is_forceselectkeyrelease) + + #define ISXimp4IM(im) (im->ximp_impart->im_proto_vnum >= XIMP_VERSION_NUMBER) + #define RECONNECTION_MODE(im) (((Ximp_XIM)(im))->ximp_impart->reconnection_mode) + #define IS_SERVER_CONNECTED(im) (((Ximp_XIM)(im))->ximp_impart->is_connected) + #define IS_LOCAL_PROCESSING(im) (((Ximp_XIM)(im))->ximp_impart->is_local) + + #define IS_IC_CONNECTED(ic) (ic->ximp_icpart->icid) + + #define IS_RECONNECTABLE(im) (RECONNECTION_MODE(im) & XIMP_RECONNECTABLE) + #define MAKE_RECONNECTABLE(im) (RECONNECTION_MODE(im) |= XIMP_RECONNECTABLE) + #define IS_DELAYBINDABLE(im) (RECONNECTION_MODE(im) & XIMP_DELAYBINDABLE) + #define MAKE_DELAYBINDABLE(im) (RECONNECTION_MODE(im) |= XIMP_DELAYBINDABLE) + #define IS_RESTARTABLE(im) (RECONNECTION_MODE(im) & XIMP_RESTARTABLE) + #define MAKE_RESTARTABLE(im) (RECONNECTION_MODE(im) |= XIMP_RESTARTABLE) + #define IS_UNCONNECTABLE(im) (RECONNECTION_MODE(im) == XIMP_NOCONNECT) + #define MAKE_UNCONNECTABLE(im) (RECONNECTION_MODE(im) = XIMP_NOCONNECT) + #define IS_CONNECTABLE(im) (RECONNECTION_MODE(im) != XIMP_NOCONNECT) + #define MAKE_CONNECTABLE(im) (RECONNECTION_MODE(im) = XIMP_RECONNECTABLE|XIMP_DELAYBINDABLE|XIMP_RESTARTABLE) + + #define ISXimp4(ic) (((Ximp_XIM)ic->core.im)->ximp_impart->im_proto_vnum >= XIMP_VERSION_NUMBER) + + #define ISFE1(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode == XIMP_FE_TYPE1) + #define ISFE2(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode == XIMP_FE_TYPE2) + #define ISFE3(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode == XIMP_FE_TYPE3) + #define ISBE1(ic) ((((Ximp_XIC)ic)->ximp_icpart->svr_mode & XIMP_BE_TYPE1) == XIMP_BE_TYPE1) + #define ISBE2(ic) ((((Ximp_XIC)ic)->ximp_icpart->svr_mode & XIMP_BE_TYPE2) == XIMP_BE_TYPE2) + #define ISSYNCBE1(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode == XIMP_SYNC_BE_TYPE1) + #define ISSYNCBE2(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode == XIMP_SYNC_BE_TYPE2) + #define ISFRONTEND(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode & XIMP_FRONTEND4) + #define ISBACKEND(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode & XIMP_BACKEND4) + #define ISTYPE1(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode & XIMP_TYPE1) + #define ISTYPE2(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode & XIMP_TYPE2) + #define ISTYPE3(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode & XIMP_TYPE3) + #define ISSYNC(ic) (((Ximp_XIC)ic)->ximp_icpart->svr_mode & XIMP_SYNC) + + #define ISXIMP3FE(ic) ((((Ximp_XIC)ic)->ximp_icpart->svr_mode & 0x03) == XIMP_FRONTEND_BC_MASK) + + #define IS_BEING_PREEDITED(ic) (((Ximp_XIC)ic)->ximp_icpart->input_mode == BEING_PREEDITED) + #define IS_FABLICATED(ic,ev) ((ic->ximp_icpart->putback_key_event) || (ev->keycode == 0)) + #define IS_USE_WCHAR(ic) (((Ximp_XIM)ic->core.im)->ximp_impart->use_wchar) + + #define ISCMOf(ev,n,x) (((XEvent*)ev)->xclient.data.l[n] == (x)) + #define ISXIMP_ERROR(ev) (((XEvent*)ev)->type == ClientMessage && ((XEvent*)ev)->xclient.format == 32 \ + && (ISCMOf(ev,0,XIMP_ERROR3) || ISCMOf(ev,0,XIMP_ERROR4))) + #define XIMP_SYNCHRONIZE(ic) {if(IS_SERVER_CONNECTED((ic->core.im)) && (IS_BEING_PREEDITED(ic)) &&\ + ((((Ximp_XIC)ic)->ximp_icpart->svr_mode) & XIMP_SYNC ))\ + _Ximp_Synchronize(ic);} + + #define XIMP_PREEDIT_MAX_LONG(ic) (ISXimp4(ic)?XIMP_PREEDIT_MAX_LONG4:XIMP_PREEDIT_MAX_LONG3) + #define XIMP_STATUS_MAX_LONG(ic) (ISXimp4(ic)?XIMP_STATUS_MAX_LONG4:XIMP_STATUS_MAX_LONG3) + + #define XIMP3_RESET_RETURN_ATOM 2 + #define XIMP4_RESET_RETURN_DETAIL 2 + #define XIMP4_RESET_RETURN_ATOM 3 + #define NO_RESET_DATA 0 + #define RESET_DATA_VIA_CM 1 + #define RESET_DATA_VIA_PROP 2 + #define XIMP_RESET_RETURN_ATOM(ic) (ISXimp4(ic)?XIMP4_RESET_RETURN_ATOM:XIMP3_RESET_RETURN_ATOM) + + #define XIMP_KEYRELEASE(ic) XIMP_KEYRELEASE4 + #define XIMP_KEYPRESS(ic) (ISXimp4(ic)?XIMP_KEYPRESS4:XIMP_KEYPRESS3) + + #define XIMP_CREATE(ic) (ISXimp4(ic)?XIMP_CREATE4:XIMP_CREATE3) + #define XIMP_DESTROY(ic) (ISXimp4(ic)?XIMP_DESTROY4:XIMP_DESTROY3) + #define XIMP_REG_KEY_PRESSED(ic) (ISXimp4(ic)?XIMP_REG_KEY_PRESSED4:XIMP_BEGIN3) + #define XIMP_SETFOCUS(ic) (ISXimp4(ic)?XIMP_SETFOCUS4:XIMP_SETFOCUS3) + #define XIMP_UNSETFOCUS(ic) (ISXimp4(ic)?XIMP_UNSETFOCUS4:XIMP_UNSETFOCUS3) + #define XIMP_CLIENT_WINDOW(ic) XIMP_CLIENT_WINDOW4 + #define XIMP_FOCUS_WINDOW(ic) XIMP_FOCUS_WINDOW4 + #define XIMP_MOVE(ic) (ISXimp4(ic)?XIMP_MOVE4:XIMP_MOVE3) + #define XIMP_RESET(ic) (ISXimp4(ic)?XIMP_RESET4:XIMP_RESET3) + #define XIMP_SETVALUE(ic) (ISXimp4(ic)?XIMP_SETVALUE4:XIMP_SETVALUE3) + #define XIMP_GETVALUE(ic) (ISXimp4(ic)?XIMP_GETVALUE4:XIMP_GETVALUE3) + + #define XIMP_PREEDITSTART_RETURN(ic) (ISXimp4(ic)?XIMP_PREEDITSTART_RETURN4:XIMP_PREEDITSTART_RETURN3) + #define XIMP_PREEDITCARET_RETURN(ic) (ISXimp4(ic)?XIMP_PREEDITCARET_RETURN4:XIMP_PREEDITCARET_RETURN3) + #define XIMP_SPROC_STARTED(ic) (ISXimp4(ic)?XIMP_SPROC_STARTED4:XIMP_PROCESS_BEGIN3) + #define XIMP_SPROC_STOPPED(ic) (ISXimp4(ic)?XIMP_SPROC_STOPPED4:XIMP_PROCESS_END3) + #define XIMP_READPROP(ic) (ISXimp4(ic)?XIMP_READPROP4:XIMP_READPROP3) + #define XIMP_CLIENT_WINDOW_RETURN(ic) XIMP_CLIENT_WINDOW_RETURN4 + #define XIMP_FOCUS_WINDOW_RETURN(ic) XIMP_FOCUS_WINDOW_RETURN4 + #define XIMP_GETVALUE_RETURN(ic) (ISXimp4(ic)?XIMP_GETVALUE_RETURN4:XIMP_GETVALUE_RETURN3) + #define XIMP_RESET_RETURN(ic) (ISXimp4(ic)?XIMP_RESET_RETURN4:XIMP_RESET_RETURN3) + #define XIMP_CREATE_RETURN(ic) (ISXimp4(ic)?XIMP_CREATE_RETURN4:XIMP_CREATE_RETURN3) + #define XIMP_KEYPRESS_RETURN(ic) XIMP_KEYPRESS_RETURN4 + #define XIMP_KEYRELEASE_RETURN(ic) XIMP_KEYRELEASE_RETURN4 + #define XIMP_EVENTMASK_NOTIFY(ic) XIMP_EVENTMASK_NOTIFY4 + #define XIMP_EVENTMASK_NOTIFY_RETURN(ic) XIMP_EVENTMASK_NOTIFY_RETURN4 + + #define XIMP_GEOMETRY(ic) (ISXimp4(ic)?XIMP_GEOMETRY4:XIMP_GEOMETRY3) + #define XIMP_PREEDITSTART(ic) (ISXimp4(ic)?XIMP_PREEDITSTART4:XIMP_PREEDITSTART3) + #define XIMP_PREEDITDONE(ic) (ISXimp4(ic)?XIMP_PREEDITDONE4:XIMP_PREEDITDONE3) + #define XIMP_PREEDITDRAW(ic) (ISXimp4(ic)?XIMP_PREEDITDRAW4:XIMP_PREEDITDRAW3) + #define XIMP_PREEDITDRAW_CM(ic) (ISXimp4(ic)?XIMP_PREEDITDRAW_CM4:XIMP_PREEDITDRAW_CM3) + #define XIMP_PREEDITDRAW_CM_TINY(ic) (ISXimp4(ic)?XIMP_PREEDITDRAW_CM_TINY4:XIMP_PREEDITDRAW_CM_TINY3) + #define XIMP_PREEDITCARET(ic) (ISXimp4(ic)?XIMP_PREEDITCARET4:XIMP_PREEDITCARET3) + #define XIMP_STATUSSTART(ic) (ISXimp4(ic)?XIMP_STATUSSTART4:XIMP_STATUSSTART3) + #define XIMP_STATUSDONE(ic) (ISXimp4(ic)?XIMP_STATUSDONE4:XIMP_STATUSDONE3) + #define XIMP_STATUSDRAW(ic) (ISXimp4(ic)?XIMP_STATUSDRAW4:XIMP_STATUSDRAW3) + #define XIMP_STATUSDRAW_CM(ic) (ISXimp4(ic)?XIMP_STATUSDRAW_CM4:XIMP_STATUSDRAW_CM3) + #define XIMP_EXTENSION(ic) (ISXimp4(ic)?XIMP_EXTENSION4:XIMP_EXTENSION3) + *** /tmp/d03717 Tue Mar 9 09:20:34 1993 --- mit/lib/X/Ximp/XimpCT.c Tue Mar 9 09:20:31 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpCT.c,v 1.4 92/04/14 13:28:38 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpCT.c,v 1.5 92/10/19 19:23:46 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 68,333 **** #include "Xlcint.h" #include "Ximplc.h" ! _get_codeset_number(lcd, lindex, msb_mask) ! Ximp_XLCd lcd; ! int lindex; ! unsigned char msb_mask; ! { ! int i, codeset_num, index_num; ! register CodeSetRec *codeset; ! register EncodingIndexRec *index_ptr; - codeset_num = lcd->ximp_lcpart->codeset_num; - codeset = lcd->ximp_lcpart->codeset; - - for (i = 0; i < codeset_num; i++, codeset++) { - index_ptr = codeset->encoding_index; - index_num = codeset->index_num; - - while (index_num--) { - if (index_ptr->lindex == lindex && index_ptr->msb_mask == msb_mask) - return i; - index_ptr++; - } - } - - return -1; - } - - EncodingRec * - _get_encoding_rec(lindex) - int lindex; - { - EncodingRec *encoding_ptr, **table_ptr; - - table_ptr = encoding_table; - - while (encoding_ptr = *table_ptr++) - if (encoding_ptr->lindex == lindex) - return encoding_ptr; - - return NULL; - } - - static int - get_encoding_index(encoding, msb_mask, char_length, gc_size) - unsigned char *encoding; - unsigned char msb_mask; - int char_length; - int gc_size; - { - EncodingRec *encoding_ptr, **table_ptr; - - table_ptr = encoding_table; - - if (msb_mask) { - while (encoding_ptr = *table_ptr++) - if (encoding_ptr->GR_encoding) { - if (encoding_ptr->char_length == char_length && - !strcmp(encoding_ptr->GR_encoding, (char *)encoding) && - encoding_ptr->GR_gc_size == gc_size) - - return encoding_ptr->lindex; - } - } else { - while (encoding_ptr = *table_ptr++) - if (encoding_ptr->GL_encoding) { - if (encoding_ptr->char_length == char_length && - !strcmp(encoding_ptr->GL_encoding, (char *)encoding) && - encoding_ptr->GL_gc_size == gc_size) - - return encoding_ptr->lindex; - } - } - - return -1; - } - - - static int - check_ESC_IF_char(encoding, len) - unsigned char *encoding; - register len; - { - register unsigned char ch, *strptr = encoding; - - if (len < 1) - return -1; - - ch = *strptr++; - if (ch >= 0x30 && ch < 0x7f) - return 1; - - while (--len > 0) { - if (ch < 0x20 || ch > 0x2f) - break; - ch = *strptr++; - } - - if (len == 0 || ch < 0x30 || ch > 0x7e) - return -1; - - return strptr - encoding; - } - int ! _check_ESC_sequence(lcd, ctext, ctext_len, GL_codeset, GR_codeset) ! Ximp_XLCd lcd; unsigned char *ctext; int ctext_len; ! int *GL_codeset, *GR_codeset; { ! unsigned char ch, msb_mask, *ctptr = ctext; ! unsigned char encoding[BUFSIZE]; ! int gc_size, char_length, lindex, encoding_len; ! int buf_len, tmp_len, skip_size; ! if (--ctext_len < 1 || *ctptr++ != 0x1b) return -1; ! tmp_len = ctext_len; ! msb_mask = GL; ! char_length = 1; ! gc_size = 94; ! ! ctext_len--; ! switch (ch = *ctptr++) { ! case '-': gc_size = 96; ! case ')': msb_mask = GR; ! case '(': ! break; ! case '$': ! if (ctext_len-- < 1) ! return -1; ! ! switch (ch = *ctptr++) { ! case ')': msb_mask = GR; ! case '(': ! char_length = 2; ! break; ! default: ! goto unknown; ! } ! break; ! case '%': ! if (ctext_len < 1) ! return -1; ! ! if (ctext_len > 4 && *ctptr++ == '/') { ! ch = *ctptr++; ! if (ch < 0x30 || ch > 0x3f) ! goto unknown; ! ch = *ctptr++; ! skip_size = (ch & 0x7f) * 128 + (*ctptr++ & 0x7f); ! ctext_len -= 4; ! if (ctext_len < skip_size) ! return -1; ! ctptr += skip_size; ! return ctptr - ctext; ! } ! goto unknown; ! default: ! unknown: ! ctptr = ctext + 1; ! ctext_len = tmp_len; ! msb_mask = char_length = gc_size = 0; ! break; ! ! } ! ! encoding_len = check_ESC_IF_char(ctptr, ctext_len); ! if (encoding_len < 0) return -1; ! strncpy((char *)encoding, (char *)ctptr, encoding_len); ! encoding[encoding_len] = 0; ! ctptr += encoding_len; ! if (char_length == 2) { ! ch = encoding[encoding_len - 1]; ! if (ch >= 0x60 && ch <=0x6f) ! char_length = 3; ! else if (ch >= 0x70 && ch <=0x7f) ! char_length = 4; ! } ! ! lindex = get_encoding_index(encoding, msb_mask, char_length, gc_size); ! if (lindex >= 0) { ! if (msb_mask) ! *GR_codeset = _get_codeset_number(lcd, lindex, GR); ! else ! *GL_codeset = _get_codeset_number(lcd, lindex, GL); ! } ! return ctptr - ctext; } int ! _check_CSI_sequence(lcd, ctext, ctext_len) ! Ximp_XLCd lcd; unsigned char *ctext; int ctext_len; { unsigned char ch, *ctptr = ctext; ! if (--ctext_len < 1 || *ctptr++ != 0x9b) return -1; ! ch = *ctptr++; ! while (ch >= 0x30 && ch < 0x40 && ctext_len > 0) { ! ctext_len--; ! ch = *ctptr++; ! } ! while (ch >= 0x20 && ch < 0x30 && ctext_len > 0) { ! ctext_len--; ! ch = *ctptr++; ! } ! ! if (ch < 0x40 || ch > 0x7e || ctext_len <= 0) return -1; ! return ctptr - ctext; } int ! _Ximp_cstostring(lcd, csstr, csstr_len, string, string_len, cs_num) ! Ximp_XLCd lcd; unsigned char *csstr; int csstr_len; unsigned char *string; int *string_len; - int cs_num; { unsigned char *csptr = csstr; unsigned char *string_ptr = string; unsigned char ch; ! CodeSetRec *codeset; ! EncodingIndexRec *encoding_index; ! int str_len, lindex, index_num; if (string_len) str_len = *string_len; else str_len = MAXINT; - codeset = lcd->ximp_lcpart->codeset + cs_num; - encoding_index = codeset->encoding_index; - index_num = codeset->index_num; - - - while (index_num--) { - lindex = encoding_index->lindex; - if (encoding_index->msb_mask == GL && - lindex >= ISO8859_1 && lindex <= JISX0201_1976_0) - break; - - encoding_index++; - } - if (index_num < 0) - return -1; - while (csstr_len > 0 && str_len > 0) { ch = *csptr++ & 0x7f; if (ch < 0x20 || ch > 0x7e) --- 68,156 ---- #include "Xlcint.h" #include "Ximplc.h" ! #define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++; ! #define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++; int ! _XlcCheckESCSequence(ctext, ctext_len, charset) unsigned char *ctext; int ctext_len; ! CharSet *charset; { ! unsigned char msb_mask, *ctptr = ctext; ! unsigned char buf[BUFSIZE]; ! int length; ! if (*ctptr++ != 0x1b) return -1; ! ! SKIP_I(ctptr); ! if (*ctptr < 0x30 && *ctptr > 0x7e) return -1; + + length = ++ctptr - ctext; + if (ctext_len < length) + return -1; ! strncpy((char *)buf, (char *)ctext, length); ! buf[length] = '\0'; ! *charset = _XlcGetCharSetFromEncoding(buf); ! return length; } int ! _XlcCheckCSISequence(ctext, ctext_len, charset) unsigned char *ctext; int ctext_len; + CharSet *charset; { unsigned char ch, *ctptr = ctext; + int length; ! if (*ctptr++ != 0x9b) return -1; ! SKIP_P(ctptr); ! SKIP_I(ctptr); ! if (*ctptr < 0x40 && *ctptr > 0x7e) return -1; + + length = ++ctptr - ctext; + if (ctext_len < length) + return -1; + + *charset = NULL; ! return length; } int ! _Xlc_cstostring(state, csstr, csstr_len, string, string_len) ! State state; unsigned char *csstr; int csstr_len; unsigned char *string; int *string_len; { unsigned char *csptr = csstr; unsigned char *string_ptr = string; unsigned char ch; ! int str_len; ! CharSet charset = *state->codeset->charset_list; + if (charset->string_encoding == False) + return -1; + if (string_len) str_len = *string_len; else str_len = MAXINT; while (csstr_len > 0 && str_len > 0) { ch = *csptr++ & 0x7f; if (ch < 0x20 || ch > 0x7e) *************** *** 346,367 **** int ! _Ximp_cstoct(lcd, csstr, csstr_len, ctext, ctext_len, cs_num) ! Ximp_XLCd lcd; unsigned char *csstr; int csstr_len; unsigned char *ctext; int *ctext_len; - int cs_num; { ! unsigned char encoding[BUFSIZE], *encoding_ptr; unsigned char *csptr = csstr; unsigned char *ctptr = ctext; ! unsigned char ch, msb_mask, min_ch, max_ch; ! EncodingRec *encoding_rec; ! CodeSetRec *codeset; ! int char_length, gc_size; ! int ct_len, tmp_len; if (ctext_len) ct_len = *ctext_len; --- 169,187 ---- int ! _Xlc_cstoct(state, csstr, csstr_len, ctext, ctext_len) ! State state; unsigned char *csstr; int csstr_len; unsigned char *ctext; int *ctext_len; { ! unsigned char encoding[BUFSIZE]; unsigned char *csptr = csstr; unsigned char *ctptr = ctext; ! unsigned char ch, side, min_ch, max_ch; ! int length, gc_num, ct_len, tmp_len; ! CharSet charset = *state->codeset->charset_list; if (ctext_len) ct_len = *ctext_len; *************** *** 368,414 **** else ct_len = MAXINT; ! codeset = lcd->ximp_lcpart->codeset + cs_num; ! if (codeset->index_num <= 0) ! return -1; ! ! encoding_rec = _get_encoding_rec(codeset->encoding_index[0].lindex); ! if (encoding_rec == NULL) ! return -1; ! ! msb_mask = codeset->encoding_index[0].msb_mask; ! char_length = encoding_rec->char_length; ! gc_size = (msb_mask == GR) ? ! encoding_rec->GR_gc_size : encoding_rec->GL_gc_size; ! ! encoding_ptr = encoding; ! *encoding_ptr++ = '\033'; ! if (char_length > 1) ! *encoding_ptr++ = '$'; ! if (gc_size == 94) { ! if (msb_mask == GL) ! *encoding_ptr++ = '('; ! else if (msb_mask == GR) ! *encoding_ptr++ = ')'; ! } else if (gc_size == 96) { ! if (msb_mask == GR) ! *encoding_ptr++ = '-'; } - strcpy((char *)encoding_ptr, (msb_mask == GR) ? - encoding_rec->GR_encoding : encoding_rec->GL_encoding); - tmp_len = strlen((char *)encoding); - if ((ct_len -= tmp_len) < 0) - return -1; - strcpy((char *)ctptr, (char *)encoding); - ctptr += tmp_len; min_ch = 0x20; max_ch = 0x7f; ! if (gc_size == 94) { max_ch--; ! if (char_length > 1 || msb_mask == GR) min_ch++; } --- 188,212 ---- else ct_len = MAXINT; ! side = charset->side; ! length = charset->length; ! gc_num = charset->gc_num; ! if (state->last_codeset != state->codeset) { ! strcpy((char *) encoding, charset->encoding); ! tmp_len = strlen((char *) encoding); ! if ((ct_len -= tmp_len) < 0) ! return -1; ! strcpy((char *) ctptr, (char *) encoding); ! ctptr += tmp_len; } min_ch = 0x20; max_ch = 0x7f; ! if (gc_num == 94) { max_ch--; ! if (length > 1 || side == GR) min_ch++; } *************** *** 417,423 **** if (ch < min_ch || ch > max_ch) if (ch != 0x09 && ch != 0x0a && ch != 0x0b) return -1; ! *ctptr++ = ch | msb_mask; csstr_len--; ct_len--; } --- 215,221 ---- if (ch < min_ch || ch > max_ch) if (ch != 0x09 && ch != 0x0a && ch != 0x0b) return -1; ! *ctptr++ = ch | side; csstr_len--; ct_len--; } *** /tmp/d03739 Tue Mar 9 09:20:45 1993 --- mit/lib/X/Ximp/XimpDefCnv.c Tue Mar 9 09:20:43 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpDefCnv.c,v 1.3 92/04/14 13:28:51 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpDefCnv.c,v 1.4 92/10/19 19:24:14 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 68,83 **** #include "Xlcint.h" #include "Ximplc.h" - static Bool def_initialize(); - static void null_proc(); static char def_mbchar(); static int def_mbstocs(), def_wcstocs(), def_cstombs(), def_cstowcs(); ! XLCdXimpMethods def_lc_methods = ! { ! def_initialize, ! null_proc, ! null_proc, def_mbchar, def_mbstocs, def_wcstocs, --- 68,88 ---- #include "Xlcint.h" #include "Ximplc.h" static char def_mbchar(); static int def_mbstocs(), def_wcstocs(), def_cstombs(), def_cstowcs(); ! static XLCdMethodsRec lcd_methods = { ! _XlcDefaultMapModifiers, ! _XDefaultCreateFontSet, ! _Ximp_OpenIM, ! }; ! ! static LCMethodsRec c_lc_methods = { ! _XlcDestroyLC, ! _XlcCreateState, ! _XlcDestroyState, ! _XlcCnvStart, ! _XlcCnvEnd, def_mbchar, def_mbstocs, def_wcstocs, *************** *** 85,109 **** def_cstowcs, }; ! static void ! null_proc(lcd) ! Ximp_XLCd lcd; { } ! static Bool ! def_initialize(lcd) ! Ximp_XLCd lcd; { ! lcd->ximp_lcpart->mb_cur_max = 1; ! lcd->ximp_lcpart->state_dependent = False; ! return True; } static char ! def_mbchar(lcd, str, lenp) ! Ximp_XLCd lcd; register char *str; register int *lenp; { --- 90,186 ---- def_cstowcs, }; ! ! XLCd ! _XlcCLoader(name) ! char *name; { + XimpLCd lcd; + #ifdef XIMP_BC + extern Bool _XimpBCSetAtr(); + #endif + + lcd = _XlcCreateLC(name, &lcd_methods, &c_lc_methods); + if (lcd == NULL) + return (XLCd) NULL; + + if (strcmp(name, "C") && strncmp(lcd->locale.codeset, "ISO8859", 7)) + goto error; + + if (_XlcLoadCodeSet(lcd) == False) + goto error; + + #ifdef XIMP_BC + if (lcd->locale.mb_cur_max == 0) + if (_XimpBCSetAtr(lcd) == False) + goto error; + #endif + + return (XLCd) lcd; + + error: + _XlcDestroyLC(lcd); + + return (XLCd) NULL; } ! static State state_list = NULL; ! ! State ! _XlcCreateState(lcd) ! XimpLCd lcd; { ! State state; ! for (state = state_list; state; state = state->next) ! if (state->is_used == False) ! break; ! ! if (state == NULL) { ! state = (State) Xmalloc(sizeof(StateRec)); ! if (state == NULL) ! return (State) NULL; ! ! state->next = state_list; ! state_list = state; ! } ! ! state->lcd = lcd; ! state->is_used = True; ! ! return state; } + void + _XlcDestroyState(state) + State state; + { + state->is_used = False; + } + + void + _XlcCnvStart(state) + State state; + { + Locale locale = &state->lcd->locale; + + state->GL_codeset = locale->initial_state_GL; + state->GR_codeset = locale->initial_state_GR; + + if (state->GL_codeset == NULL) + state->GL_codeset = *locale->codeset_list; + } + + void + _XlcCnvEnd(state) + State state; + { + } + + static char ! def_mbchar(state, str, lenp) ! State state; register char *str; register int *lenp; { *************** *** 113,141 **** } static int ! def_mbstocs(lcd, mbstr, mbstr_len, csbuf, csbuf_len, cs_number, char_length) ! Ximp_XLCd lcd; unsigned char *mbstr; register int mbstr_len; register unsigned char *csbuf; int *csbuf_len; - int *cs_number; - int *char_length; { ! register unsigned char *mbptr = mbstr; if (csbuf_len && mbstr_len > *csbuf_len) mbstr_len = *csbuf_len; ! while (mbstr_len--) ! *csbuf++ = *mbptr++; ! if (cs_number) ! *cs_number = 0; - if (char_length) - *char_length = 1; - if (csbuf_len) *csbuf_len = mbptr - mbstr; --- 190,219 ---- } static int ! def_mbstocs(state, mbstr, mbstr_len, csbuf, csbuf_len) ! State state; unsigned char *mbstr; register int mbstr_len; register unsigned char *csbuf; int *csbuf_len; { ! register unsigned char *mbptr = mbstr, msb_mask; if (csbuf_len && mbstr_len > *csbuf_len) mbstr_len = *csbuf_len; ! msb_mask = *mbptr & 0x80; ! while (mbstr_len--) { ! *csbuf++ = *mbptr++ & 0x7f; ! if ((*mbptr & 0x80) != msb_mask) ! break; ! } ! if (msb_mask && state->GR_codeset) ! state->codeset = state->GR_codeset; ! else ! state->codeset = state->GL_codeset; if (csbuf_len) *csbuf_len = mbptr - mbstr; *************** *** 143,171 **** } static int ! def_wcstocs(lcd, wcstr, wcstr_len, csbuf, csbuf_len, cs_number, char_length) ! Ximp_XLCd lcd; wchar_t *wcstr; register int wcstr_len; register unsigned char *csbuf; int *csbuf_len; - int *cs_number; - int *char_length; { ! register wchar_t *wcptr = wcstr; if (csbuf_len && wcstr_len > *csbuf_len) wcstr_len = *csbuf_len; ! while (wcstr_len--) ! *csbuf++ = (unsigned char) *wcptr++; ! if (cs_number) ! *cs_number = 0; - if (char_length) - *char_length = 1; - if (csbuf_len) *csbuf_len = wcptr - wcstr; --- 221,252 ---- } static int ! def_wcstocs(state, wcstr, wcstr_len, csbuf, csbuf_len) ! State state; wchar_t *wcstr; register int wcstr_len; register unsigned char *csbuf; int *csbuf_len; { ! register wchar_t *wcptr = wcstr, msb_mask; ! unsigned long wc_encode_mask = state->lcd->locale.wc_encode_mask; ! int num = state->lcd->locale.codeset_num; if (csbuf_len && wcstr_len > *csbuf_len) wcstr_len = *csbuf_len; ! msb_mask = *wcptr & wc_encode_mask; ! while (wcstr_len--) { ! *csbuf++ = (unsigned char) *wcptr++ & 0x7f; ! if ((*wcptr & wc_encode_mask) != msb_mask) ! break; ! } ! if (msb_mask && state->GR_codeset) ! state->codeset = state->GR_codeset; ! else ! state->codeset = state->GL_codeset; if (csbuf_len) *csbuf_len = wcptr - wcstr; *************** *** 173,185 **** } static int ! def_cstombs(lcd, csstr, csstr_len, mbbuf, mbbuf_len, cs_number) ! Ximp_XLCd lcd; unsigned char *csstr; register int csstr_len; register unsigned char *mbbuf; int *mbbuf_len; - int cs_number; { register unsigned char *csptr = csstr; --- 254,265 ---- } static int ! def_cstombs(state, csstr, csstr_len, mbbuf, mbbuf_len) ! State state; unsigned char *csstr; register int csstr_len; register unsigned char *mbbuf; int *mbbuf_len; { register unsigned char *csptr = csstr; *************** *** 186,193 **** if (mbbuf_len && csstr_len > *mbbuf_len) csstr_len = *mbbuf_len; ! while (csstr_len--) ! *mbbuf++ = *csptr++; if (mbbuf_len) *mbbuf_len = csptr - csstr; --- 266,278 ---- if (mbbuf_len && csstr_len > *mbbuf_len) csstr_len = *mbbuf_len; ! if (state->codeset->side) { ! while (csstr_len--) ! *mbbuf++ = *csptr++ | 0x80; ! } else { ! while (csstr_len--) ! *mbbuf++ = *csptr++ & 0x7f; ! } if (mbbuf_len) *mbbuf_len = csptr - csstr; *************** *** 196,219 **** } static int ! def_cstowcs(lcd, csstr, csstr_len, wcbuf, wcbuf_len, cs_number) ! Ximp_XLCd lcd; unsigned char *csstr; int csstr_len; ! wchar_t *wcbuf; int *wcbuf_len; - int cs_number; { register unsigned char *csptr = csstr; if (wcbuf_len && csstr_len > *wcbuf_len) csstr_len = *wcbuf_len; while (csstr_len--) ! *wcbuf++ = (wchar_t) *csptr++; if (wcbuf_len) *wcbuf_len = csptr - csstr; return csptr - csstr; } --- 281,700 ---- } static int ! def_cstowcs(state, csstr, csstr_len, wcbuf, wcbuf_len) ! State state; unsigned char *csstr; int csstr_len; ! register wchar_t *wcbuf; int *wcbuf_len; { register unsigned char *csptr = csstr; + unsigned long wc_encoding = state->codeset->wc_encoding; if (wcbuf_len && csstr_len > *wcbuf_len) csstr_len = *wcbuf_len; while (csstr_len--) ! *wcbuf++ = (wchar_t) (*csptr++ & 0x7f) | wc_encoding; if (wcbuf_len) *wcbuf_len = csptr - csstr; + + return csptr - csstr; + } + + + static LCMethodsRec default_lc_methods = { + _XlcDestroyLC, + _XlcCreateState, + _XlcDestroyState, + _XlcCnvStart, + _XlcCnvEnd, + _Xlc_mbchar, + _Xlc_mbstocs, + _Xlc_wcstocs, + _Xlc_cstombs, + _Xlc_cstowcs, + }; + + XLCd + _XlcGenericLoader(name) + char *name; + { + XimpLCd lcd; + + lcd = _XlcCreateLC(name, &lcd_methods, &default_lc_methods); + if (lcd == NULL) + return (XLCd) NULL; + + if (_XlcLoadCodeSet(lcd) == False) + goto error; + + return (XLCd) lcd; + + error: + _XlcDestroyLC(lcd); + + return (XLCd) NULL; + } + + static int + compare(src, encoding, length) + register char *src; + register char *encoding; + register int length; + { + char *start = src; + + while (length-- > 0) { + if (*src++ != *encoding++) + return 0; + if (*encoding == '\0') + return src - start; + } + + return 0; + } + + static Bool + mbtocs(state, src_data, dst_data) + State state; + register CvtData src_data, dst_data; + { + Locale locale = &state->lcd->locale; + ParseInfo *parse_list, parse_info; + CodeSet codeset; + char *src = src_data->string.multi_byte; + char *dst = dst_data->string.multi_byte; + unsigned char ch, side; + int length, number, encoding_len = 0; + register i; + + if (locale->mb_parse_table) { + number = locale->mb_parse_table[(unsigned char) *src]; + if (number > 0) { + parse_list = locale->mb_parse_list + number - 1; + for ( ; parse_info = *parse_list; parse_list++) { + encoding_len = compare(src, parse_info->encoding, + src_data->length); + if (encoding_len > 0) { + switch (parse_info->type) { + case E_SS: + src += encoding_len; + codeset = parse_info->codeset; + goto found; + case E_LSL: + case E_LSR: + src += encoding_len; + if (parse_info->type == E_LSL) + state->GL_codeset = parse_info->codeset; + else + state->GR_codeset = parse_info->codeset; + length = 0; + codeset = parse_info->codeset; + goto end; + case E_GL: + codeset = state->GL_codeset; + goto found; + case E_GR: + codeset = state->GR_codeset; + goto found; + } + } + } + } + } + + if ((*src & 0x80) && state->GR_codeset) + codeset = state->GR_codeset; + else + codeset = state->GL_codeset; + + found: + if (codeset == NULL) + return False; + + length = codeset->length; + if (length > src_data->length - encoding_len) + return False; + + if (dst) { + if (length > dst_data->length) + return False; + side = (*(codeset->charset_list))->side; + for (i = 0; i < length; i++) + *dst++ = (*src++ & 0x7f) | side; + dst_data->string.multi_byte = dst; + dst_data->length -= length; + } + end: + src_data->string.multi_byte = src; + src_data->length -= encoding_len + length; + src_data->cvt_length = encoding_len + length; + dst_data->cvt_length = length; + dst_data->codeset = codeset; + + return True; + } + + char + _Xlc_mbchar(state, str, lenp) + State state; + char *str; + int *lenp; + { + CvtDataRec src_data_rec, dst_data_rec; + register CvtData src_data = &src_data_rec; + register CvtData dst_data = &dst_data_rec; + char buf[BUFSIZE]; + register int length; + + src_data->string.multi_byte = str; + src_data->length = strlen(str) + 1; + dst_data->string.multi_byte = buf; + dst_data->length = BUFSIZE; + + length = 0; + while (1) { + if (mbtocs(state, src_data, dst_data) == False) { + *lenp = length; + return '\0'; + } + length += src_data->cvt_length; + if (dst_data->cvt_length > 0) { + state->codeset = dst_data->codeset; + *lenp = length; + return buf[0]; + } + } + } + + int + _Xlc_mbstocs(state, mbstr, mbstr_len, csbuf, csbuf_len) + State state; + char *mbstr; + int mbstr_len; + char *csbuf; + int *csbuf_len; + { + CvtDataRec src_data_rec, dst_data_rec; + register CvtData src_data = &src_data_rec; + register CvtData dst_data = &dst_data_rec; + CodeSet codeset; + register int src_cvt_length, dst_cvt_length; + + src_data->string.multi_byte = mbstr; + src_data->length = mbstr_len; + dst_data->string.multi_byte = csbuf; + dst_data->length = csbuf_len ? *csbuf_len : MAXINT; + + if (mbtocs(state, src_data, dst_data) == False) + return -1; + codeset = dst_data->codeset; + src_cvt_length = src_data->cvt_length; + dst_cvt_length = dst_data->cvt_length; + + while (mbtocs(state, src_data, dst_data) == True) { + if (dst_data->codeset != codeset) + break; + + src_cvt_length += src_data->cvt_length; + dst_cvt_length += dst_data->cvt_length; + } + + state->codeset = codeset; + if (csbuf_len) + *csbuf_len = dst_cvt_length; + + return src_cvt_length; + } + + static CodeSet + wc_parse_codeset(state, wcstr) + State state; + wchar_t *wcstr; + { + Locale locale = &state->lcd->locale; + CodeSet *codeset; + wchar_t wch; + unsigned long wc_encoding; + int num; + + wch = *wcstr; + wc_encoding = wch & locale->wc_encode_mask; + num = locale->codeset_num; + codeset = locale->codeset_list; + while (num-- > 0) { + if (wc_encoding == (*codeset)->wc_encoding) + return *codeset; + codeset++; + } + + return NULL; + } + + int + _Xlc_wcstocs(state, wcstr, wcstr_len, csbuf, csbuf_len) + State state; + wchar_t *wcstr; + int wcstr_len; + unsigned char *csbuf; + int *csbuf_len; + { + wchar_t *wcptr = wcstr; + register unsigned char *bufptr = csbuf; + register wchar_t wch; + unsigned char *tmpptr; + int buf_len; + register length; + Locale locale = &state->lcd->locale; + CodeSet codeset; + unsigned long wc_encoding; + + if (csbuf_len) + buf_len = *csbuf_len; + else + buf_len = MAXINT; + + codeset = wc_parse_codeset(state, wcptr); + wc_encoding = codeset->wc_encoding; + + if (wcstr_len < buf_len / codeset->length) + buf_len = wcstr_len * codeset->length; + + for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) { + wch = *wcptr; + if ((wch & locale->wc_encode_mask) != wc_encoding) + break; + length = codeset->length; + buf_len -= length; + bufptr += length; + + tmpptr = bufptr - 1; + while (length--) { + *tmpptr-- = (unsigned char) ((wch & 0x7f) | codeset->side); + wch >>= locale->wc_shift_bits; + } + } + + if (csbuf_len) + *csbuf_len = bufptr - csbuf; + + state->codeset = codeset; + + return wcptr - wcstr; + } + + int + _Xlc_cstombs(state, csstr, csstr_len, mbbuf, mbbuf_len) + State state; + unsigned char *csstr; + int csstr_len; + unsigned char *mbbuf; + int *mbbuf_len; + { + register unsigned char *csptr = csstr; + register unsigned char *bufptr = mbbuf; + register buf_len; + int num, encoding_len = 0; + CodeSet codeset = state->codeset; + EncodingType type; + + if (mbbuf_len) + buf_len = *mbbuf_len; + else + buf_len = MAXINT; + + if (codeset->parse_info) { + switch (type = codeset->parse_info->type) { + case E_SS: + encoding_len = strlen(codeset->parse_info->encoding); + break; + case E_LSL: + case E_LSR: + if (type == E_LSL) { + if (codeset == state->GL_codeset) + break; + } else { + if (codeset == state->GR_codeset) + break; + } + encoding_len = strlen((char *) codeset->parse_info->encoding); + if (encoding_len > buf_len) + return -1; + strcpy((char *)bufptr, codeset->parse_info->encoding); + bufptr += encoding_len; + buf_len -= encoding_len; + encoding_len = 0; + if (type == E_LSL) + state->GL_codeset = codeset; + else + state->GR_codeset = codeset; + break; + } + } + + csstr_len /= codeset->length; + buf_len /= codeset->length + encoding_len; + if (csstr_len < buf_len) + buf_len = csstr_len; + + while (buf_len--) { + if (encoding_len) { + strcpy((char *) bufptr, codeset->parse_info->encoding); + bufptr += encoding_len; + } + num = codeset->length; + while (num--) + *bufptr++ = (*csptr++ & 0x7f) | codeset->side; + } + + if (mbbuf_len) + *mbbuf_len = bufptr - mbbuf; + + return csptr - csstr; + } + + int + _Xlc_cstowcs(state, csstr, csstr_len, wcbuf, wcbuf_len) + State state; + unsigned char *csstr; + int csstr_len; + wchar_t *wcbuf; + int *wcbuf_len; + { + register unsigned char *csptr = csstr; + wchar_t *bufptr = wcbuf; + register wchar_t wch; + register buf_len; + unsigned long code_mask, wc_encoding; + int num, length, wc_shift_bits; + + if (wcbuf_len) + buf_len = *wcbuf_len; + else + buf_len = MAXINT; + + length = state->codeset->length; + csstr_len /= length; + if (csstr_len < buf_len) + buf_len = csstr_len; + + code_mask = ~state->lcd->locale.wc_encode_mask; + wc_encoding = state->codeset->wc_encoding; + wc_shift_bits = state->lcd->locale.wc_shift_bits; + + while (buf_len--) { + wch = (wchar_t) (*csptr++ & 0x7f); + num = length - 1; + while (num--) + wch = (wch << wc_shift_bits) | (*csptr++ & 0x7f); + + *bufptr++ = (wch & code_mask) | wc_encoding; + } + + if (wcbuf_len) + *wcbuf_len = bufptr - wcbuf; return csptr - csstr; } *** /tmp/d03761 Tue Mar 9 09:20:57 1993 --- mit/lib/X/Ximp/XimpDrStr.c Tue Mar 9 09:20:54 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpDrStr.c,v 1.2 92/04/14 13:28:54 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpDrStr.c,v 1.3 92/10/19 19:24:18 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 71,94 **** */ { ! Ximp_XLCd lcd = (Ximp_XLCd) xfont_set->core.lcd; unsigned char *strptr, strbuf[BUFSIZE]; unsigned char xchar_buf[BUFSIZE]; XChar2b xchar2b_buf[BUFSIZE]; - FontSetRec *fontset; XFontStruct *font; int (*cnv_func)(); - int cset_num, char_length; int count, length, tmp_len; ! cnv_func = lcd->ximp_lcpart->methods->CNV_FUNC; ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); while (text_length > 0) { length = BUFSIZE; ! count = (*cnv_func)(lcd, text, text_length, strbuf, &length, ! &cset_num, &char_length); if (count <= 0) break; --- 71,95 ---- */ { ! XLCd lcd = xfont_set->core.lcd; unsigned char *strptr, strbuf[BUFSIZE]; unsigned char xchar_buf[BUFSIZE]; XChar2b xchar2b_buf[BUFSIZE]; XFontStruct *font; int (*cnv_func)(); int count, length, tmp_len; + int xx = x; + LCMethods methods = LC_METHODS(lcd); + State state; ! cnv_func = methods->CNV_FUNC; ! state = (*methods->create_state)(lcd); ! (*methods->cnv_start)(state); while (text_length > 0) { length = BUFSIZE; ! count = (*cnv_func)(state, text, text_length, strbuf, &length); if (count <= 0) break; *************** *** 96,117 **** text_length -= count; strptr = strbuf; - fontset = ((Ximp_XFontSet) xfont_set)->ximp_fspart->fontset + cset_num; - if (fontset == NULL) - continue; while (length > 0) { tmp_len = BUFSIZE; ! if (char_length < 2) ! count = _Ximp_cstoxchar(fontset, strptr, length, ! xchar_buf, &tmp_len, &font); else ! count = _Ximp_cstoxchar2b(fontset, strptr, length, ! xchar2b_buf, &tmp_len, &font); if (count <= 0) break; XSetFont(dpy, gc, font->fid); ! if (char_length < 2) { XDrawString(dpy, d, gc, x, y, (char *)xchar_buf, tmp_len); x += XTextWidth(font, (char *)xchar_buf, tmp_len); } else { --- 97,115 ---- text_length -= count; strptr = strbuf; while (length > 0) { tmp_len = BUFSIZE; ! if (state->codeset->length < 2) ! count = _Ximp_cstoxchar(xfont_set, strptr, length, xchar_buf, ! &tmp_len, state->codeset, &font); else ! count = _Ximp_cstoxchar2b(xfont_set, strptr, length, xchar2b_buf, ! &tmp_len, state->codeset, &font); if (count <= 0) break; XSetFont(dpy, gc, font->fid); ! if (state->codeset->length < 2) { XDrawString(dpy, d, gc, x, y, (char *)xchar_buf, tmp_len); x += XTextWidth(font, (char *)xchar_buf, tmp_len); } else { *************** *** 123,127 **** } } ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); } --- 121,127 ---- } } ! (*methods->cnv_end)(state); ! (*methods->destroy_state)(state); ! x -= xx; } *** /tmp/d03783 Tue Mar 9 09:21:08 1993 --- mit/lib/X/Ximp/XimpEUC.c Tue Mar 9 09:21:05 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpEUC.c,v 1.4 92/04/14 13:28:56 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpEUC.c,v 1.5 92/10/19 19:24:22 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 70,546 **** #include "Ximplc.h" ! static Bool euc_initialize(); ! static void euc_cnv_start(), euc_cnv_end(); ! static char euc_mbchar(); ! static int euc_mbstocs(), euc_wcstocs(), euc_cstombs(), euc_cstowcs(); ! typedef struct { ! int max_char_length; ! } EUCExtRec; ! ! XLCdXimpMethods euc_lc_methods = { ! euc_initialize, ! euc_cnv_start, ! euc_cnv_end, ! euc_mbchar, ! euc_mbstocs, ! euc_wcstocs, ! euc_cstombs, ! euc_cstowcs, }; #ifndef SS2 ! #define SS2 0x8e ! #define SS3 0x8f ! #endif ! #define WC_MASK 0x8080 ! #define CS1_WC_MASK 0x8080 ! #define CS2_WC_MASK 0x0080 ! #define CS3_WC_MASK 0x8000 #define SHIFT_BITS 8 ! #define CODE_MASK 0x7f7f ! #define WC_MASK_L 0x30000000 ! #define CS1_WC_MASK_L 0x30000000 ! #define CS2_WC_MASK_L 0x10000000 ! #define CS3_WC_MASK_L 0x20000000 ! #define SHIFT_BITS_L 7 ! #define CODE_MASK_L 0x0fffffff ! static int CS1_length, CS2_length, CS3_length, Shift_bits; ! static wchar_t WC_mask, CS1_WC_mask, CS2_WC_mask, CS3_WC_mask, Code_mask; ! ! static Bool ! euc_initialize(lcd) ! Ximp_XLCd lcd; { ! register int codeset_num; ! register CodeSetRec *codeset; ! EUCExtRec *extension; ! int mb_cur_max, max_char_length; ! mb_cur_max = max_char_length = 1; ! codeset = lcd->ximp_lcpart->codeset; ! if ((codeset_num = lcd->ximp_lcpart->codeset_num) > 4) ! codeset_num = lcd->ximp_lcpart->codeset_num = 4; ! switch (codeset_num) { ! case 4: ! mb_cur_max = max(mb_cur_max, codeset[3].char_length + 1); ! max_char_length = max(max_char_length, codeset[3].char_length); ! case 3: ! mb_cur_max = max(mb_cur_max, codeset[2].char_length + 1); ! max_char_length = max(max_char_length, codeset[2].char_length); ! case 2: ! mb_cur_max = max(mb_cur_max, codeset[1].char_length); ! max_char_length = max(max_char_length, codeset[1].char_length); ! } ! lcd->ximp_lcpart->mb_cur_max = mb_cur_max; ! lcd->ximp_lcpart->state_dependent = False; ! ! if ((extension = (EUCExtRec *) Xmalloc(sizeof(EUCExtRec))) == NULL) ! return False; ! extension->max_char_length = max_char_length; ! lcd->ximp_lcpart->extension = (XPointer) extension; ! ! return True; ! } ! ! static void ! euc_cnv_start(lcd) ! Ximp_XLCd lcd; ! { ! register int codeset_num; ! register CodeSetRec *codeset; ! static Ximp_XLCd last_lcd = NULL; ! int max_char_length; ! ! if (lcd == last_lcd) ! return; ! ! codeset = lcd->ximp_lcpart->codeset; ! codeset_num = lcd->ximp_lcpart->codeset_num; ! ! #ifdef FIX_EUC32 ! WC_mask = WC_MASK_L; ! CS1_WC_mask = CS1_WC_MASK_L; ! CS2_WC_mask = CS2_WC_MASK_L; ! CS3_WC_mask = CS3_WC_MASK_L; ! Shift_bits = SHIFT_BITS_L; ! Code_mask = CODE_MASK_L; ! #else ! max_char_length = ! ((EUCExtRec *) lcd->ximp_lcpart->extension)->max_char_length; ! if (max_char_length < 3) { ! WC_mask = WC_MASK; ! CS1_WC_mask = CS1_WC_MASK; ! CS2_WC_mask = CS2_WC_MASK; ! CS3_WC_mask = CS3_WC_MASK; ! Shift_bits = SHIFT_BITS; ! Code_mask = CODE_MASK; ! } else { ! WC_mask = WC_MASK_L; ! CS1_WC_mask = CS1_WC_MASK_L; ! CS2_WC_mask = CS2_WC_MASK_L; ! CS3_WC_mask = CS3_WC_MASK_L; ! Shift_bits = SHIFT_BITS_L; ! Code_mask = CODE_MASK_L; ! } ! #endif ! ! CS1_length = CS2_length = CS3_length = 0; ! ! switch (codeset_num) { ! case 4: ! CS3_length = codeset[3].char_length; case 3: ! CS2_length = codeset[2].char_length; case 2: ! CS1_length = codeset[1].char_length; ! } ! ! last_lcd = lcd; ! } ! ! static void ! euc_cnv_end(lcd) ! Ximp_XLCd lcd; ! { ! } ! ! static char ! euc_mbchar(lcd, str, lenp) ! Ximp_XLCd lcd; ! register char *str; ! register int *lenp; ! { ! register unsigned char ch = (unsigned char) *str++; ! ! if ((ch & 0x80) == NULL) { ! cset0: ! *lenp = 1; ! return (char) ch; ! } ! ! if (ch == SS2) { ! if (CS2_length == 0) ! goto cset0; ! *lenp = CS2_length + 1; ! return *str; ! } ! ! if (ch == SS3) { ! if (CS3_length == 0) ! goto cset0; ! *lenp = CS3_length + 1; ! return *str; ! } ! ! if (CS1_length == 0) ! goto cset0; ! *lenp = CS1_length; ! return (char) ch; ! } ! ! ! static int ! euc_mbstocs(lcd, mbstr, mbstr_len, csbuf, csbuf_len, cs_number, char_length) ! Ximp_XLCd lcd; ! unsigned char *mbstr; ! int mbstr_len; ! unsigned char *csbuf; ! int *csbuf_len; ! int *cs_number; ! int *char_length; ! { ! register unsigned char *mbptr = mbstr; ! register unsigned char *bufptr = csbuf; ! register unsigned char ch; ! unsigned char *tmpptr; ! int buf_len; ! register length; ! int codeset_number = -1, tmp_number; ! ! if (csbuf_len) ! buf_len = *csbuf_len; ! else ! buf_len = MAXINT; ! ! while (mbstr_len > 0 && buf_len > 0) { ! ch = *mbptr; ! if ((ch & 0x80) == NULL) { ! cset0: ! if (codeset_number) { ! if (codeset_number != -1) ! break; ! codeset_number = 0; ! if (char_length) ! *char_length = 1; ! } ! ! *bufptr++ = ch; ! mbptr++; ! mbstr_len--; ! buf_len--; ! continue; ! } ! ! tmpptr = mbptr; ! ! if (ch == SS2 || ch == SS3) { ! if (ch == SS2) { ! length = CS2_length; ! tmp_number = 2; ! } else { ! length = CS3_length; ! tmp_number = 3; ! } ! if (length < 1) ! goto cset0; ! ! if (mbstr_len < length + 1 || buf_len < length) ! break; ! ++mbptr; ! mbstr_len--; ! } else { ! if ((length = CS1_length) < 1) ! goto cset0; ! ! if (mbstr_len < length || buf_len < length) ! break; ! tmp_number = 1; ! } ! ! if (codeset_number != tmp_number) { ! if (codeset_number != -1) { ! mbptr = tmpptr; ! break; ! } ! codeset_number = tmp_number; ! if (char_length) ! *char_length = length; ! } ! ! mbstr_len -= length; ! buf_len -= length; ! ! while (length--) ! *bufptr++ = *mbptr++; ! ! } ! ! if (csbuf_len) ! *csbuf_len = bufptr - csbuf; ! if (cs_number) ! *cs_number = codeset_number; ! ! return mbptr - mbstr; ! } ! ! ! static int ! euc_wcstocs(lcd, wcstr, wcstr_len, csbuf, csbuf_len, cs_number, char_length) ! Ximp_XLCd lcd; ! wchar_t *wcstr; ! int wcstr_len; ! unsigned char *csbuf; ! int *csbuf_len; ! int *cs_number; ! int *char_length; ! { ! wchar_t *wcptr = wcstr, wc_mask; ! register unsigned char *bufptr = csbuf; ! register wchar_t wch; ! unsigned char *tmpptr; ! int buf_len; ! register length; ! int codeset_number = -1, tmp_number; ! ! if (csbuf_len) ! buf_len = *csbuf_len; ! else ! buf_len = MAXINT; ! ! for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) { ! wch = *wcptr; ! wc_mask = wch & WC_mask; ! if (wc_mask == NULL) { ! cset0: ! if (codeset_number) { ! if (codeset_number != -1) ! break; ! codeset_number = 0; ! if (char_length) ! *char_length = 1; ! } ! *bufptr++ = (unsigned char) wch; ! buf_len--; ! continue; ! } else if (wc_mask == CS1_WC_mask) { ! length = CS1_length; ! tmp_number = 1; ! } else if (wc_mask == CS2_WC_mask) { ! length = CS2_length; ! tmp_number = 2; ! } else { ! length = CS3_length; ! tmp_number = 3; ! } ! ! if (length < 1) ! goto cset0; ! if (buf_len < length) break; - if (codeset_number != tmp_number) { - if (codeset_number != -1) - break; - codeset_number = tmp_number; - if (char_length) - *char_length = length; - } - buf_len -= length; - bufptr += length; - - tmpptr = bufptr - 1; - while (length--) { - *tmpptr-- = (unsigned char) (wch | 0x80); - wch >>= Shift_bits; - } } ! if (csbuf_len) ! *csbuf_len = bufptr - csbuf; ! if (cs_number) ! *cs_number = codeset_number; ! return wcptr - wcstr; } ! ! static int ! euc_cstombs(lcd, csstr, csstr_len, mbbuf, mbbuf_len, cs_number) ! Ximp_XLCd lcd; ! unsigned char *csstr; ! int csstr_len; ! unsigned char *mbbuf; ! int *mbbuf_len; ! int cs_number; { ! register unsigned char *csptr = csstr; ! register unsigned char *bufptr = mbbuf; ! register buf_len; ! int length; ! unsigned char ss; ! int num; ! if (mbbuf_len) ! buf_len = *mbbuf_len; ! else ! buf_len = MAXINT; ! if (cs_number == 0) { ! cset0: ! if (csstr_len < buf_len) ! buf_len = csstr_len; ! while (buf_len--) ! *bufptr++ = *csptr++ & 0x7f; ! } else if (cs_number == 1) { ! if (CS1_length < 1) ! goto cset0; ! if (csstr_len < buf_len) ! buf_len = csstr_len; ! buf_len -= buf_len % CS1_length; ! while (buf_len--) ! *bufptr++ = *csptr++ | 0x80; ! } else { ! if (cs_number == 2) { ! length = CS2_length; ! ss = SS2; ! } else { ! length = CS3_length; ! ss = SS3; ! } ! csstr_len /= length; ! buf_len /= (length + 1); ! if (csstr_len < buf_len) ! buf_len = csstr_len; ! while (buf_len--) { ! *bufptr++ = ss; ! num = length; ! while (num--) ! *bufptr++ = *csptr++ | 0x80; ! } ! } ! if (mbbuf_len) ! *mbbuf_len = bufptr - mbbuf; ! return csptr - csstr; ! } ! static int ! euc_cstowcs(lcd, csstr, csstr_len, wcbuf, wcbuf_len, cs_number) ! Ximp_XLCd lcd; ! unsigned char *csstr; ! int csstr_len; ! wchar_t *wcbuf; ! int *wcbuf_len; ! int cs_number; ! { ! register unsigned char *csptr = csstr; ! wchar_t *bufptr = wcbuf, wc_mask; ! register wchar_t wch; ! register buf_len; ! int length; ! int num; ! ! if (wcbuf_len) ! buf_len = *wcbuf_len; ! else ! buf_len = MAXINT; ! ! if (cs_number == 0) { ! cset0: ! if (csstr_len < buf_len) ! buf_len = csstr_len; ! while (buf_len--) ! *bufptr++ = (wchar_t) (*csptr++ & 0x7f); ! } else { ! if (cs_number == 1) { ! length = CS1_length; ! wc_mask = CS1_WC_mask; ! } else if (cs_number == 2) { ! length = CS2_length; ! wc_mask = CS2_WC_mask; ! } else { ! length = CS3_length; ! wc_mask = CS3_WC_mask; ! } ! if (length < 1) ! goto cset0; ! ! csstr_len /= length; ! if (csstr_len < buf_len) ! buf_len = csstr_len; ! ! while (buf_len--) { ! wch = *csptr++; ! num = length - 1; ! while (num--) ! wch = (wch << Shift_bits) | *csptr++; ! ! *bufptr++ = (wch & Code_mask) | wc_mask; ! } ! } ! ! if (wcbuf_len) ! *wcbuf_len = bufptr - wcbuf; ! ! return csptr - csstr; } --- 70,191 ---- #include "Ximplc.h" ! static XLCdMethodsRec lcd_methods = { ! _XlcDefaultMapModifiers, ! _XDefaultCreateFontSet, ! _Ximp_OpenIM, ! }; ! static LCMethodsRec lc_methods = { ! _XlcDestroyLC, ! _XlcCreateState, ! _XlcDestroyState, ! _XlcCnvStart, ! _XlcCnvEnd, ! _Xlc_mbchar, ! _Xlc_mbstocs, ! _Xlc_wcstocs, ! _Xlc_cstombs, ! _Xlc_cstowcs, }; + #ifdef XIMP_BC #ifndef SS2 ! #define SS2 0x8e ! #define SS3 0x8f ! #endif /* SS2 */ ! #ifdef SVR4 ! #define WC_MASK 0x30000000 ! #define CS1_WC_MASK 0x30000000 ! #define CS2_WC_MASK 0x10000000 ! #define CS3_WC_MASK 0x20000000 ! #define SHIFT_BITS 7 ! #else /* SVR4 */ ! #define WC_MASK 0x00008080 ! #define CS1_WC_MASK 0x00008080 ! #define CS2_WC_MASK 0x00000080 ! #define CS3_WC_MASK 0x00008000 #define SHIFT_BITS 8 ! #endif /* SVR4 */ ! extern _XlcAddParseList(); ! Bool ! _XimpBCSetAtr(lcd) ! XimpLCd lcd; { ! Locale locale = &lcd->locale; ! CodeSet codeset; ! char tmp_str[2]; ! int cs_num; ! cs_num = locale->codeset_num; ! if (cs_num > 4) ! locale->codeset_num = cs_num = 4; ! locale->mb_cur_max = 1; ! locale->wc_encode_mask = WC_MASK; ! locale->wc_shift_bits = SHIFT_BITS; ! switch (--cs_num) { case 3: ! codeset = locale->codeset_list[3]; ! locale->mb_cur_max = max(codeset->length, locale->mb_cur_max); ! tmp_str[0] = SS3; ! tmp_str[1] = '\0'; ! if (_XlcAddParseList(locale, E_SS, tmp_str, codeset) == False) ! return False; ! codeset->wc_encoding = CS3_WC_MASK; case 2: ! codeset = locale->codeset_list[2]; ! locale->mb_cur_max = max(codeset->length, locale->mb_cur_max); ! tmp_str[0] = SS2; ! tmp_str[1] = '\0'; ! if (_XlcAddParseList(locale, E_SS, tmp_str, codeset) == False) ! return False; ! codeset->wc_encoding = CS2_WC_MASK; ! case 1: ! codeset = locale->codeset_list[1]; ! locale->mb_cur_max = max(codeset->length, locale->mb_cur_max); ! codeset->wc_encoding = CS1_WC_MASK; ! locale->initial_state_GR = codeset; break; } ! locale->initial_state_GL = locale->codeset_list[0]; ! return True; } + #endif /* XIMP_BC */ ! XLCd ! _XlcEUCLoader(name) ! char *name; { ! XimpLCd lcd; + lcd = _XlcCreateLC(name, &lcd_methods, &lc_methods); + if (lcd == NULL) + return (XLCd) NULL; ! if (strcmp(lcd->locale.codeset, "EUC")) ! goto error; ! if (_XlcLoadCodeSet(lcd) == False) ! goto error; ! #ifdef XIMP_BC ! if (lcd->locale.mb_cur_max == 0) ! if (_XimpBCSetAtr(lcd) == False) ! goto error; ! #endif ! return (XLCd) lcd; + error: + _XlcDestroyLC(lcd); ! return (XLCd) NULL; } *** /tmp/d03805 Tue Mar 9 09:21:20 1993 --- mit/lib/X/Ximp/XimpExten.c Tue Mar 9 09:21:17 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpExten.c,v 1.6 92/07/29 10:15:43 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED. --- 1,4 ---- ! /* $XConsortium: XimpExten.c,v 1.7 92/10/19 19:24:25 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED. *************** *** 113,118 **** --- 113,120 ---- extern Ximp_XIC _Ximp_LookupXIC(); extern void _Ximp_IM_SendMessage(); extern void _Ximp_ProcError(); + extern void _Ximp_ConvertOn(); + extern void _Ximp_ConvertOff(); #define Private static /* *************** *** 184,189 **** --- 186,192 ---- Private int ximp_ext_conversion(); Private int ximp_ext_statuswindow(); Private int ximp_ext_error(); + #ifdef EXTLOOKUPCALLBACK Private int ximp_ext_lookup_begin(); Private int ximp_ext_lookup_start_callback(); Private int ximp_ext_lookup_draw_callback(); *************** *** 193,198 **** --- 196,202 ---- Private int ximp_ext_aux_draw_callback(); Private int ximp_ext_aux_process_callback(); Private int ximp_ext_aux_done_callback(); + #endif Private int ximp_ext_restart_callback(); Private int ximp_ext_destroy_callback(); Private int nested_list(); *************** *** 206,215 **** Private icop_t icoptbl[] = { ! XNExtXimp_Backfront, ximp_ext_backfront, XNExtXimp_Conversion, ximp_ext_conversion, XNExtXimp_Statuswindow, ximp_ext_statuswindow, XNExtXimp_Error, ximp_ext_error, XNExtXimp_LookupAttributes, nested_list, XNExtXimp_LookupStartCallback, ximp_ext_lookup_start_callback, XNExtXimp_LookupDrawCallback, ximp_ext_lookup_draw_callback, --- 210,220 ---- Private icop_t icoptbl[] = { ! XNExtXimp_Backfront, ximp_ext_backfront, XNExtXimp_Conversion, ximp_ext_conversion, XNExtXimp_Statuswindow, ximp_ext_statuswindow, XNExtXimp_Error, ximp_ext_error, + #ifdef EXTLOOKUPCALLBACK XNExtXimp_LookupAttributes, nested_list, XNExtXimp_LookupStartCallback, ximp_ext_lookup_start_callback, XNExtXimp_LookupDrawCallback, ximp_ext_lookup_draw_callback, *************** *** 221,226 **** --- 226,232 ---- XNExtXimp_AuxProcessCallback, ximp_ext_aux_process_callback, XNExtXimp_AuxDoneCallback, ximp_ext_aux_done_callback, XNExtXimp_LookupBegin, ximp_ext_lookup_begin, + #endif XNExtXimp_RestartCallback, ximp_ext_restart_callback, XNExtXimp_DestroyCallback, ximp_ext_destroy_callback, /* *************** *** 245,263 **** { Ximp_ExtXIMRec *ext_im = (Ximp_ExtXIMRec *)(((Ximp_XIM)ic->core.im)->ximp_impart)->imtype; ! if (!(ext_im->extension_back_front_exist)) ! return (False); ! switch (op) { ! case XICOpCreate: ! case XICOpSet: ! ic->ximp_icpart->is_bep_mode = (int) value; ! return (True); ! break; ! case XICOpGet: ! *((long *) value) = (long)(ic->ximp_icpart->is_bep_mode); ! return (True); ! break; } return (False); } --- 251,291 ---- { Ximp_ExtXIMRec *ext_im = (Ximp_ExtXIMRec *)(((Ximp_XIM)ic->core.im)->ximp_impart)->imtype; ! /* For Backward Compatibility */ ! if(IS_SERVER_CONNECTED(ic->core.im)) { ! if(!ISXimp4(ic)) { ! if (!(ext_im->extension_back_front_exist)) ! return (False); ! } ! } switch (op) { ! case XICOpCreate: ! /* For Backward Compatibility */ ! if(ISXimp4(ic)){ ! /* This value is already set in Ximp4.0 */ ! return(True); /* Only return(True) */ ! } ! if(((int)value) == XIMP_FRONTEND) { ! ic->ximp_icpart->svr_mode = ((ic->ximp_icpart->svr_mode & ~(XIMP_BACKEND_BC_MASK)) | XIMP_FRONTEND_BC_MASK); ! return (True); ! } else if(((int)value) == XIMP_BACKEND) { ! ic->ximp_icpart->svr_mode = ((ic->ximp_icpart->svr_mode & ~(XIMP_FRONTEND_BC_MASK)) | XIMP_BACKEND_BC_MASK); ! return (True); ! } ! break; /*XXX*/ ! ! case XICOpSet: ! return (False); /* This should set at the IC creation time. */ ! ! case XICOpGet: ! if(ISFRONTEND(ic)) { ! *((long *) value) = (long)(XIMP_FRONTEND); ! return (True); ! } else if(ISBACKEND(ic)) { ! *((long *) value) = (long)(XIMP_BACKEND); ! return (True); ! } ! break; /*XXX*/ } return (False); } *************** *** 309,340 **** Display *d, XEvent *ev, XPointer arg0 ! ) #else ximp_ext_conversionPredicate(d, ev, arg0) Display *d; ! XEvent *ev; XPointer arg0; #endif { XimpConversionPredArg arg = (XimpConversionPredArg) arg0; ! ! if( ev->type == ClientMessage ) { ! if( ev->xclient.message_type == arg->message_type && ! ev->xclient.format == 32 && ev->xclient.data.l[1] == arg->icid ) { ! if( ev->xclient.data.l[0] == XIMP_ERROR ) ! return( True ); ! else if( ev->xclient.data.l[0] == XIMP_EXTENSION && ! ev->xclient.data.l[2] == arg->ext_type ) ! return( True ); } ! } else if( ev->type == DestroyNotify ) { ! if( ev->xdestroywindow.window == arg->owner ) { ! return( True ); } } ! return( False ); } Private int --- 337,371 ---- Display *d, XEvent *ev, XPointer arg0 ! ) #else ximp_ext_conversionPredicate(d, ev, arg0) Display *d; ! XEvent *ev; XPointer arg0; #endif { XimpConversionPredArg arg = (XimpConversionPredArg) arg0; ! ! Ximp_XIC ic; ! ! if ((ev->type == ClientMessage) && (ev->xclient.format ==32)) { ! ic = _Ximp_LookupXIC(ev->xclient.data.l[1]); ! if (ev->xclient.message_type == arg->message_type && ev->xclient.data.l[1] == arg->icid ) { ! if(ISXIMP_ERROR(ev)) { ! return(True); ! } else if(ev->xclient.data.l[0] == XIMP_EXTENSION(ic)) { ! if(ev->xclient.data.l[2] == arg->ext_type) ! return(True); ! } } ! } else if (ev->type == DestroyNotify) { ! if (ev->xdestroywindow.window == arg->owner) { ! return(True); } } ! return(False); } Private int *************** *** 353,389 **** switch (op) { case XICOpCreate: case XICOpSet: ! if(ic->ximp_icpart->icid == NULL) { ! if(((Ximp_XIM)ic->core.im)->ximp_impart->inputserver) ! return (False); ! return (True); ! } /* * Set Conversion mode on/off */ ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION, ! ext_im->extension_conversion_id, ! True, /* SetICVelues */ ! value); /* * This call expect IM Server to report new conversion state to Ximp * lib right after setting. */ return True; - break; case XICOpGet: ! if( ic->ximp_icpart->icid == NULL ) { ! if(((Ximp_XIM)ic->core.im)->ximp_impart->inputserver) ! return( False ); ! *((long *) value) = (long)(ext_im->extension_conversion); ! return (True); } ! _Ximp_IM_SendMessage( ic, XIMP_EXTENSION, ! ext_im->extension_conversion_id, ! False, /* GetICVelues */ ! value ); Arg.message_type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; ! Arg.ext_type = ext_im->extension_conversion_id; Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; Arg.icid = ic->ximp_icpart->icid; if( !_XimpIfEvent( ic, &event, ximp_ext_conversionPredicate, (XPointer)&Arg ) ) --- 384,426 ---- switch (op) { case XICOpCreate: case XICOpSet: ! if(!IS_SERVER_CONNECTED(ic->core.im)) { ! if(IS_CONNECTABLE(ic->core.im)) ! return(True); ! return(False); ! } /* * Set Conversion mode on/off */ ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION(ic), ! ext_im->extension_conversion_id, ! True, /* SetICVelues */ ! value); ! if(ISXimp4(ic)) { ! if(value == XIMEnable) /* on */ ! _Ximp_ConvertOn(ic); ! else /* off */ ! _Ximp_ConvertOff(ic); ! } /* * This call expect IM Server to report new conversion state to Ximp * lib right after setting. */ return True; case XICOpGet: ! if(!IS_SERVER_CONNECTED(ic->core.im)) { ! if(IS_CONNECTABLE(ic->core.im)) { ! *((long *) value) = (long)(ext_im->extension_conversion); ! return(True); ! } ! return(False); } ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION(ic), ! ext_im->extension_conversion_id, ! False, /* GetICVelues */ ! value); Arg.message_type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; ! Arg.ext_type = ext_im->extension_conversion_id; Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; Arg.icid = ic->ximp_icpart->icid; if( !_XimpIfEvent( ic, &event, ximp_ext_conversionPredicate, (XPointer)&Arg ) ) *************** *** 454,463 **** --- 491,549 ---- return (False); } + Private int + ximp_ext_restart_callback( ic, op, value ) + Ximp_XIC ic; + XICOp_t op; + long value; + { + switch( op ) { + case XICOpCreate: + case XICOpSet: + ic->ximp_icpart->restart.client_data = ((XIMCallback *)value)->client_data; + ic->ximp_icpart->restart.callback = ((XIMCallback *)value)->callback; + return( True ); + break; + + case XICOpGet: + if( ic->ximp_icpart->restart.callback != NULL ) { + ((XIMCallback *)value)->callback = ic->ximp_icpart->restart.callback; + return( True ); + } + break; + } + return( False ); + } + + Private int + ximp_ext_destroy_callback( ic, op, value ) + Ximp_XIC ic; + XICOp_t op; + long value; + { + switch( op ) { + case XICOpCreate: + case XICOpSet: + ic->ximp_icpart->destroy.client_data = ((XIMCallback *)value)->client_data; + ic->ximp_icpart->destroy.callback = ((XIMCallback *)value)->callback; + return( True ); + break; + + case XICOpGet: + if( ic->ximp_icpart->destroy.callback != NULL ) { + ((XIMCallback *)value)->callback = ic->ximp_icpart->destroy.callback; + return( True ); + } + break; + } + return( False ); + } + /* * Ximp extentions * XIMP_EXT_XIMP_LOOKUPCHOICES */ + #ifdef EXTLOOKUPCALLBACK Private int ximp_ext_lookup_start_callback(ic, op, value) *************** *** 661,673 **** ic->ximp_icpart->use_lookup_choices = True ; break ; case XICOpSet: ! if(ic->ximp_icpart->icid == NULL) { ! if(((Ximp_XIM)ic->core.im)->ximp_impart->inputserver) ! return (False); ! return (True); ! } ic->ximp_icpart->use_lookup_choices = True ; ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION, ext_im->extension_lookup_id, LOOKUP_CHOICES_BEGIN, NULL); --- 747,757 ---- ic->ximp_icpart->use_lookup_choices = True ; break ; case XICOpSet: ! if(!IS_IC_CONNECTED(ic)) { ! return False; ! } ic->ximp_icpart->use_lookup_choices = True ; ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION(ic), ext_im->extension_lookup_id, LOOKUP_CHOICES_BEGIN, NULL); *************** *** 682,733 **** return (False); } - Private int - ximp_ext_restart_callback( ic, op, value ) - Ximp_XIC ic; - XICOp_t op; - long value; - { - switch( op ) { - case XICOpCreate: - case XICOpSet: - ic->ximp_icpart->restart.client_data = ((XIMCallback *)value)->client_data; - ic->ximp_icpart->restart.callback = ((XIMCallback *)value)->callback; - return( True ); - break; - - case XICOpGet: - /* - * NOT surely implemented Yet. Need attention. - */ - break; - } - return( False ); - } - - Private int - ximp_ext_destroy_callback( ic, op, value ) - Ximp_XIC ic; - XICOp_t op; - long value; - { - switch( op ) { - case XICOpCreate: - case XICOpSet: - ic->ximp_icpart->destroy.client_data = ((XIMCallback *)value)->client_data; - ic->ximp_icpart->destroy.callback = ((XIMCallback *)value)->callback; - return( True ); - break; - - case XICOpGet: - /* - * NOT surely implemented Yet. Need attention. - */ - break; - } - return( False ); - } - static void _Ximp_Extlookupstart(); static void _Ximp_Extlookupdraw(); static void _Ximp_Extlookupprocess(); --- 766,771 ---- *************** *** 846,856 **** XFlush(ic->core.im->core.display); ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION, ! ext_im->extension_lookup_id, ! LOOKUP_CHOICES_START_REP, ! ext_im->extension_lookup_start_rep, ! NULL); XFlush(ic->core.im->core.display); --- 884,894 ---- XFlush(ic->core.im->core.display); ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION(ic), ! ext_im->extension_lookup_id, ! LOOKUP_CHOICES_START_REP, ! ext_im->extension_lookup_start_rep, ! NULL); XFlush(ic->core.im->core.display); *************** *** 1029,1039 **** ext_im = (Ximp_ExtXIMRec *) (((Ximp_XIMRec *) ic->core.im)->ximp_impart->imtype); ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION, ! ext_im->extension_lookup_id, ! LOOKUP_CHOICES_PROCESS_REP, ! xim_proc.index_of_choice_selected, ! NULL); XFlush(ic->core.im->core.display); } --- 1067,1077 ---- ext_im = (Ximp_ExtXIMRec *) (((Ximp_XIMRec *) ic->core.im)->ximp_impart->imtype); ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION(ic), ! ext_im->extension_lookup_id, ! LOOKUP_CHOICES_PROCESS_REP, ! xim_proc.index_of_choice_selected, ! NULL); XFlush(ic->core.im->core.display); } *************** *** 1057,1062 **** --- 1095,1101 ---- ic->ximp_icpart->lookup_attr.draw_data = NULL ; } } + #endif /* EXTLOOKUPCALLBACK */ /* * Following functions are called by Core of Ximp. *************** *** 1221,1229 **** int mode; { if(mode == XIMP_CREATE_IC) ! return _Ximp_ext_icop(ic, name, XICOpCreate, value); else ! return _Ximp_ext_icop(ic, name, XICOpSet, value); } /* --- 1260,1268 ---- int mode; { if(mode == XIMP_CREATE_IC) ! return _Ximp_ext_icop(ic, name, XICOpCreate, value); else ! return _Ximp_ext_icop(ic, name, XICOpSet, value); } /* *************** *** 1253,1272 **** ext_im = (Ximp_ExtXIMRec *) (((Ximp_XIMRec *) ic->core.im)->ximp_impart->imtype); /* Backend / Frontend */ ! if (ic->ximp_icpart->is_bep_mode == XIMP_BACKEND) { ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION, ! ext_im->extension_back_front_id, ! ic->ximp_icpart->is_bep_mode, ! NULL); } /* Lookup Choice using check */ if((ext_im->extension_lookup_exist)) { if ( ic->ximp_icpart->use_lookup_choices ) { ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION, ! ext_im->extension_lookup_id, ! LOOKUP_CHOICES_BEGIN, ! NULL); } } /* Add extension here */ --- 1292,1314 ---- ext_im = (Ximp_ExtXIMRec *) (((Ximp_XIMRec *) ic->core.im)->ximp_impart->imtype); /* Backend / Frontend */ ! /* For Backward Compatibility */ ! if(!ISXimp4(ic)) { ! if (!ISXIMP3FE(ic)) { ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION(ic), ! ext_im->extension_back_front_id, ! ic->ximp_icpart->svr_mode, ! NULL); ! } } /* Lookup Choice using check */ if((ext_im->extension_lookup_exist)) { if ( ic->ximp_icpart->use_lookup_choices ) { ! _Ximp_IM_SendMessage(ic, XIMP_EXTENSION(ic), ! ext_im->extension_lookup_id, ! LOOKUP_CHOICES_BEGIN, ! NULL); } } /* Add extension here */ *************** *** 1298,1307 **** --- 1340,1351 ---- ext_im = (Ximp_ExtXIMRec *) im_impart->imtype; if (ext_id == ext_im->extension_lookup_id) { + #ifdef EXTLOOKUPCALLBACK if (ext_im->extension_lookup_exist) _Ximp_ExtLookup(d, w, ev, ic); return; /* anything to do it? */ + #endif } else; /* Add extension here */ return; *** /tmp/d03827 Tue Mar 9 09:21:33 1993 --- mit/lib/X/Ximp/XimpICG.c Tue Mar 9 09:21:30 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpICG.c,v 1.9 92/07/29 10:15:56 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED. --- 1,4 ---- ! /* $XConsortium: XimpICG.c,v 1.10 92/10/19 19:24:35 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED. *************** *** 28,34 **** Author: Takashi Fujiwara FUJITSU LIMITED Hideki Hiura Sun Microsystems, Inc. ! Makoto Wakamatsu Sony Corporation ******************************************************************/ --- 28,34 ---- Author: Takashi Fujiwara FUJITSU LIMITED Hideki Hiura Sun Microsystems, Inc. ! Makoto Wakamatsu Sony Corporaion ******************************************************************/ *************** *** 42,409 **** extern char *_Ximp_GetICValues(); extern Bool _Ximp_GetICExtension(); ! extern Bool _Ximp_CMPredicate(); static Bool _Ximp_PreGetAttributes(); static Bool _Ximp_StatusGetAttributes(); - static XPointer _Ximp_GetRequestIM(); char * _Ximp_GetICValues(ic, values) ! Ximp_XIC ic; ! XIMArg *values; { ! XIMArg *p; ! char *p_char; ! char *return_name = NULL; ! int len; ! for(p = values; p->name != NULL; p++) { ! if(strcmp(p->name, XNInputStyle) == 0) { ! if(ic->ximp_icpart->value_mask & XIMP_INPUT_STYLE) { ! *((XIMStyle *)(p->value)) = ic->core.input_style; ! } else { ! return_name = p->name; ! break; ! } ! } else if(strcmp(p->name, XNClientWindow)==0) { ! if(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN) { ! *((Window *)(p->value)) = ic->core.client_window; ! } else { ! return_name = p->name; ! break; ! } ! } else if(strcmp(p->name, XNFocusWindow)==0) { ! if(ic->ximp_icpart->proto_mask & XIMP_FOCUS_WIN_MASK) { ! *((Window *)(p->value)) = ic->core.focus_window; ! } else if(((Ximp_XIM)ic->core.im)->ximp_impart->inputserver){ ! return_name = p->name; ! break; ! } else { ! XPointer tmp = _Ximp_GetRequestIM(ic, ! XIMP_FOCUS_WIN_MASK, ! ((Ximp_XIM)ic->core.im)->ximp_impart->focus_win_id, ! XA_WINDOW); ! *((Window *)(p->value)) = *(Window *)tmp ; ! free(tmp) ; ! } ! } else if(strcmp(p->name, XNResourceName)==0) { ! if(ic->core.im->core.res_name != (char *)NULL) { ! len = strlen(ic->core.im->core.res_name); ! if((p_char = Xmalloc(len+1)) == NULL) { ! return_name = p->name; ! break; ! } ! strcpy(p_char, ic->core.im->core.res_name); ! *((char **)(p->value)) = p_char; ! } else { ! return_name = p->name; ! break; ! } ! } else if(strcmp(p->name, XNResourceClass)==0) { ! if(ic->core.im->core.res_class != (char *)NULL) { ! len = strlen(ic->core.im->core.res_class); ! if((p_char = Xmalloc(len+1)) == NULL) { ! return_name = p->name; ! break; ! } ! strcpy(p_char, ic->core.im->core.res_name); ! *((char **)(p->value)) = p_char; ! } else { ! return_name = p->name; ! break; ! } ! } else if(strcmp(p->name, XNGeometryCallback)==0) { ! if(ic->ximp_icpart->value_mask & XIMP_GEOMETRY_CB) { ! *((XIMCallback *)(p->value)) = ic->core.geometry_callback; ! } else { ! return_name = p->name; ! break; ! } ! } else if(strcmp(p->name, XNFilterEvents)==0) { ! *((unsigned long *)(p->value)) = ic->core.filter_events; ! } else if(strcmp(p->name, XNPreeditAttributes)==0) { ! if( _Ximp_PreGetAttributes(ic, p->value, ! &return_name) == False) ! break; ! } else if(strcmp(p->name, XNStatusAttributes)==0) { ! if( _Ximp_StatusGetAttributes(ic, p->value, ! &return_name) == False) ! break; ! } else { ! if( _Ximp_GetICExtension(ic, p->name, p->value) == False) { ! return_name = p->name; ! break; ! } } } ! return(return_name); } static Bool _Ximp_PreGetAttributes(ic, vl, return_name) ! Ximp_XIC ic; ! XIMArg *vl; ! char **return_name; { ! XIMArg *p; ! XRectangle *p_rect; ! XPoint *p_point; ! unsigned long mask; ! int im_preedit_flag = 0; ! Ximp_PreeditPropRec *preedit_data = NULL; ! XIMCallback *p_callback; ! if(((Ximp_XIM)ic->core.im)->ximp_impart->connectserver) { ! for(mask = 0, p = vl; p->name != NULL; p++) { ! if(strcmp(p->name, XNArea)==0) ! mask |= XIMP_PRE_AREA_MASK; ! else if(strcmp(p->name, XNAreaNeeded)==0) ! mask |= XIMP_PRE_AREANEED_MASK; ! else if(strcmp(p->name, XNSpotLocation)==0) { ! if(!ic->ximp_icpart->input_mode) ! _Ximp_IM_SendMessage(ic, XIMP_MOVE, ! ic->ximp_icpart->preedit_attr.SpotLocation.x, ! ic->ximp_icpart->preedit_attr.SpotLocation.y, ! NULL); ! mask |= XIMP_PRE_SPOTL_MASK; ! } ! else if(strcmp(p->name, XNColormap)==0) ! mask |= XIMP_PRE_COLORMAP_MASK; ! else if(strcmp(p->name, XNStdColormap)==0) ! mask |= XIMP_PRE_COLORMAP_MASK; ! else if(strcmp(p->name, XNBackground)==0) ! mask |= XIMP_PRE_BG_MASK; ! else if(strcmp(p->name, XNForeground)==0) ! mask |= XIMP_PRE_FG_MASK; ! else if(strcmp(p->name, XNBackgroundPixmap)==0) ! mask |= XIMP_PRE_BGPIXMAP_MASK; ! else if(strcmp(p->name, XNLineSpace)==0) ! mask |= XIMP_PRE_LINESP_MASK; ! else if(strcmp(p->name, XNCursor)==0) ! mask |= XIMP_PRE_CURSOR_MASK; } ! if(mask) { ! preedit_data = (Ximp_PreeditPropRec *)_Ximp_GetRequestIM(ic, mask, ! ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id, ! ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id); ! if(preedit_data != (Ximp_PreeditPropRec *)NULL) ! im_preedit_flag = 1; ! } } ! for(p = vl; p->name != NULL; p++) { ! if(strcmp(p->name, XNArea)==0) { ! if(im_preedit_flag) { ! if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_rect->x = preedit_data->Area.x; ! p_rect->y = preedit_data->Area.y; ! p_rect->width = preedit_data->Area.width; ! p_rect->height = preedit_data->Area.height; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_PRE_AREA_MASK) { ! if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_rect->x = ic->core.preedit_attr.area.x; ! p_rect->y = ic->core.preedit_attr.area.y; ! p_rect->width = ic->core.preedit_attr.area.width; ! p_rect->height = ic->core.preedit_attr.area.height; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! *((XRectangle **)(p->value)) = p_rect; ! } else if(strcmp(p->name, XNAreaNeeded)==0) { ! if(im_preedit_flag) { ! if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_rect->x = p_rect->y = 0; ! p_rect->width = preedit_data->AreaNeeded.width; ! p_rect->height = preedit_data->AreaNeeded.height; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_PRE_AREANEED_MASK) { ! if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_rect->x = p_rect->y = 0; ! p_rect->width = ic->core.preedit_attr.area_needed.width; ! p_rect->height = ic->core.preedit_attr.area_needed.height; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! *((XRectangle **)(p->value)) = p_rect; ! } else if(strcmp(p->name, XNSpotLocation)==0) { ! if(im_preedit_flag) { ! if((p_point = (XPoint *)Xmalloc(sizeof(XPoint))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_point->x = preedit_data->SpotLocation.x; ! p_point->y = preedit_data->SpotLocation.y; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_PRE_SPOTL_MASK) { ! if((p_point = (XPoint *)Xmalloc(sizeof(XPoint))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_point->x = ic->core.preedit_attr.spot_location.x; ! p_point->y = ic->core.preedit_attr.spot_location.y; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! *((XPoint **)(p->value)) = p_point; ! } else if( strcmp(p->name, XNColormap)==0 ! || strcmp(p->name, XNStdColormap)==0) { ! if(im_preedit_flag) { ! *((Colormap *)(p->value)) = preedit_data->Colormap; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_PRE_COLORMAP_MASK) { ! *((Colormap *)(p->value)) = ic->core.preedit_attr.colormap; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNBackground)==0) { ! if(im_preedit_flag) { ! *((unsigned long *)(p->value)) = preedit_data->Background; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_PRE_BG_MASK) { ! *((unsigned long *)(p->value)) = ic->core.preedit_attr.background; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNForeground)==0) { ! if(im_preedit_flag) { ! *((unsigned long *)(p->value)) = preedit_data->Foreground; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_PRE_FG_MASK) { ! *((unsigned long *)(p->value)) = ic->core.preedit_attr.foreground; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNBackgroundPixmap)==0) { ! if(im_preedit_flag) { ! *((Pixmap *)(p->value)) = preedit_data->Bg_Pixmap; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_PRE_BGPIXMAP_MASK) { ! *((Pixmap *)(p->value)) = ic->core.preedit_attr.background_pixmap; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNFontSet)==0) { ! if(ic->ximp_icpart->proto_mask & XIMP_PRE_FONT_MASK) { ! *((XFontSet *)(p->value)) = ic->core.preedit_attr.fontset; ! } else { ! *return_name = p->name; ! return(False); ! } ! } else if(strcmp(p->name, XNLineSpace)==0) { ! if(im_preedit_flag) { ! *((int *)(p->value)) = preedit_data->LineSpacing; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_PRE_LINESP_MASK) { ! *((int *)(p->value)) = ic->core.preedit_attr.line_space; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNCursor)==0) { ! if(im_preedit_flag) { ! *((Cursor *)(p->value)) = preedit_data->Cursor; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_PRE_CURSOR_MASK) { ! *((Cursor *)(p->value)) = ic->core.preedit_attr.cursor; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNPreeditStartCallback)==0) { ! if((int)ic->core.preedit_attr.callbacks.start.callback) { ! if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_callback->client_data = ! ic->core.preedit_attr.callbacks.start.client_data; ! p_callback->callback = ! ic->core.preedit_attr.callbacks.start.callback; ! *((XIMCallback **)(p->value)) = p_callback; ! } else { ! *return_name = p->name; ! return(False); ! } ! } else if(strcmp(p->name, XNPreeditDrawCallback)==0) { ! if((int)ic->core.preedit_attr.callbacks.draw.callback) { ! if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_callback->client_data = ! ic->core.preedit_attr.callbacks.draw.client_data; ! p_callback->callback = ! ic->core.preedit_attr.callbacks.draw.callback; ! *((XIMCallback **)(p->value)) = p_callback; ! } else { ! *return_name = p->name; ! return(False); ! } ! } else if(strcmp(p->name, XNPreeditDoneCallback)==0) { ! if((int)ic->core.preedit_attr.callbacks.done.callback) { ! if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_callback->client_data = ! ic->core.preedit_attr.callbacks.done.client_data; ! p_callback->callback = ! ic->core.preedit_attr.callbacks.done.callback; ! *((XIMCallback **)(p->value)) = p_callback; ! } else { ! *return_name = p->name; ! return(False); ! } ! } else if(strcmp(p->name, XNPreeditCaretCallback)==0) { ! if((int)ic->core.preedit_attr.callbacks.caret.callback) { ! if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_callback->client_data = ! ic->core.preedit_attr.callbacks.caret.client_data; ! p_callback->callback = ! ic->core.preedit_attr.callbacks.caret.callback; ! *((XIMCallback **)(p->value)) = p_callback; ! } else { ! *return_name = p->name; ! return(False); ! } } } ! if( preedit_data ) ! XFree(preedit_data); ! return(True); } static Bool --- 42,483 ---- extern char *_Ximp_GetICValues(); extern Bool _Ximp_GetICExtension(); ! extern Bool _Ximp_CMPredicate32(); static Bool _Ximp_PreGetAttributes(); static Bool _Ximp_StatusGetAttributes(); + static XPointer + _Ximp_GetRequestIM(ic, mask, get_atom_id, atom_id) + Ximp_XIC ic; + unsigned long mask; + Atom get_atom_id, atom_id; + { + XEvent event; + Atom actual_type_ret; + int actual_format_ret; + unsigned long nitems_ret; + unsigned long bytes_after_ret; + unsigned char *data; + XimpCMPredicateArgRec Arg; + + if(!IS_IC_CONNECTED(ic)) + return(NULL); + if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) + return(NULL); + + _Ximp_IM_SendMessage(ic, XIMP_GETVALUE(ic), mask, NULL, NULL); + Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; + Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; + Arg.protocol = XIMP_GETVALUE_RETURN(ic); + Arg.icid = ic->ximp_icpart->icid; + if( !_XimpIfEvent( ic, &event, _Ximp_CMPredicate32, (XPointer)&Arg ) ) + return( NULL ); + + XGetWindowProperty(ic->core.im->core.display, + ic->core.client_window, + get_atom_id, 0L, 1000000L, True, atom_id, + &actual_type_ret, &actual_format_ret, &nitems_ret, + &bytes_after_ret, &data); + + if(actual_format_ret == 0 || nitems_ret == 0) + return(NULL); + return((XPointer)data); + } + char * _Ximp_GetICValues(ic, values) ! Ximp_XIC ic; ! XIMArg *values; { ! XIMArg *p; ! char *p_char; ! char *return_name = NULL; ! int len; ! if(!IS_SERVER_CONNECTED(ic->core.im) && IS_RECONNECTABLE(ic->core.im)) ! _Ximp_ConnectServer( ic->core.im ); ! if( IS_SERVER_CONNECTED(ic->core.im) && !IS_IC_CONNECTED(ic) ) ! if( _Ximp_ConnectIC( ic, XIMP_START_IC ) ) ! if(IS_RESTARTABLE(ic->core.im)) ! _Ximp_CallRestartCallbackExtension( ic ); ! ! for(p = values; p->name != NULL; p++) { ! if(strcmp(p->name, XNInputStyle) == 0) { ! if(ic->ximp_icpart->value_mask & XIMP_INPUT_STYLE) { ! *((XIMStyle *)(p->value)) = ic->core.input_style; ! } else { ! return_name = p->name; ! break; ! } ! } else if(strcmp(p->name, XNClientWindow)==0) { ! if(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN) { ! *((Window *)(p->value)) = ic->core.client_window; ! } else { ! return_name = p->name; ! break; ! } ! } else if(strcmp(p->name, XNFocusWindow)==0) { ! if(XIMP_CHK_FOCUSWINMASK(ic)) { ! *((Window *)(p->value)) = ic->core.focus_window; ! } else if(IS_IC_CONNECTED(ic)) { ! XPointer tmp = _Ximp_GetRequestIM(ic, ! XIMP_FOCUS_WIN_MASK(ic), ! ((Ximp_XIM)ic->core.im)->ximp_impart->focus_win_id, ! XA_WINDOW); ! *((Window *)(p->value)) = *(Window *)tmp ; ! free(tmp) ; ! } else { ! return_name = p->name; ! break; ! } ! } else if(strcmp(p->name, XNResourceName)==0) { ! if(ic->core.im->core.res_name != (char *)NULL) { ! len = strlen(ic->core.im->core.res_name); ! if((p_char = Xmalloc(len+1)) == NULL) { ! return_name = p->name; ! break; } + strcpy(p_char, ic->core.im->core.res_name); + *((char **)(p->value)) = p_char; + } else { + return_name = p->name; + break; + } + } else if(strcmp(p->name, XNResourceClass)==0) { + if(ic->core.im->core.res_class != (char *)NULL) { + len = strlen(ic->core.im->core.res_class); + if((p_char = Xmalloc(len+1)) == NULL) { + return_name = p->name; + break; + } + strcpy(p_char, ic->core.im->core.res_class); + *((char **)(p->value)) = p_char; + } else { + return_name = p->name; + break; + } + } else if(strcmp(p->name, XNGeometryCallback)==0) { + if(ic->ximp_icpart->value_mask & XIMP_GEOMETRY_CB) { + *((XIMCallback *)(p->value)) = ic->core.geometry_callback; + } else { + return_name = p->name; + break; + } + } else if(strcmp(p->name, XNFilterEvents)==0) { + *((unsigned long *)(p->value)) = ic->core.filter_events; + } else if(strcmp(p->name, XNPreeditAttributes)==0) { + if( _Ximp_PreGetAttributes(ic, p->value, &return_name) == False) + break; + } else if(strcmp(p->name, XNStatusAttributes)==0) { + if( _Ximp_StatusGetAttributes(ic, p->value, &return_name) == False) + break; + } else { + if( _Ximp_GetICExtension(ic, p->name, p->value) == False) { + return_name = p->name; + break; + } } ! } ! return(return_name); } static Bool _Ximp_PreGetAttributes(ic, vl, return_name) ! Ximp_XIC ic; ! XIMArg *vl; ! char **return_name; { ! XIMArg *p; ! XRectangle *p_rect; ! XPoint *p_point; ! unsigned long mask; ! int im_preedit_flag = 0; ! Ximp_PreeditPropRec4 *preedit_data = NULL; ! Ximp_PreeditPropRec3 *preedit_data_bc = NULL; ! XIMCallback *p_callback; ! if(IS_IC_CONNECTED(ic)){ ! for(mask = 0, p = vl; p->name != NULL; p++) { ! if(strcmp(p->name, XNArea)==0) ! mask |= XIMP_PRE_AREA_MASK(ic); ! else if(strcmp(p->name, XNAreaNeeded)==0) ! mask |= XIMP_PRE_AREANEED_MASK(ic); ! else if(strcmp(p->name, XNSpotLocation)==0) { ! if(!IS_BEING_PREEDITED(ic)) ! _Ximp_IM_SendMessage(ic, XIMP_MOVE(ic), ! ic->ximp_icpart->preedit_attr.SpotLocation.x, ! ic->ximp_icpart->preedit_attr.SpotLocation.y, ! NULL); ! mask |= XIMP_PRE_SPOTL_MASK(ic); ! } ! else if(strcmp(p->name, XNColormap)==0) ! mask |= XIMP_PRE_COLORMAP_MASK(ic); ! else if(strcmp(p->name, XNStdColormap)==0) ! mask |= XIMP_PRE_STD_COLORMAP_MASK(ic); ! else if(strcmp(p->name, XNBackground)==0) ! mask |= XIMP_PRE_BG_MASK(ic); ! else if(strcmp(p->name, XNForeground)==0) ! mask |= XIMP_PRE_FG_MASK(ic); ! else if(strcmp(p->name, XNBackgroundPixmap)==0) ! mask |= XIMP_PRE_BGPIXMAP_MASK(ic); ! else if(strcmp(p->name, XNLineSpace)==0) ! mask |= XIMP_PRE_LINESP_MASK(ic); ! else if(strcmp(p->name, XNCursor)==0) ! mask |= XIMP_PRE_CURSOR_MASK(ic); ! } ! if(mask) { ! preedit_data = (Ximp_PreeditPropRec4 *)_Ximp_GetRequestIM(ic, ! mask, ! ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id, ! ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id); ! if(preedit_data != (Ximp_PreeditPropRec4 *)NULL) { ! im_preedit_flag = 1; ! if( !ISXimp4(ic) ) { ! preedit_data_bc = (Ximp_PreeditPropRec3 *)preedit_data; ! if( (preedit_data = (Ximp_PreeditPropRec4 *)Xmalloc(sizeof(Ximp_PreeditPropRec4))) == NULL ) { ! im_preedit_flag = 0; ! } ! else { ! preedit_data->Area = preedit_data_bc->Area; ! preedit_data->AreaNeeded = preedit_data_bc->AreaNeeded; ! preedit_data->SpotLocation = preedit_data_bc->SpotLocation; ! preedit_data->Colormap = preedit_data_bc->Colormap; ! preedit_data->StdColormap = preedit_data_bc->Colormap; ! preedit_data->Foreground = preedit_data_bc->Foreground; ! preedit_data->Background = preedit_data_bc->Background; ! preedit_data->Bg_Pixmap = preedit_data_bc->Bg_Pixmap; ! preedit_data->LineSpacing = preedit_data_bc->LineSpacing; ! preedit_data->Cursor = preedit_data_bc->Cursor; ! } ! XFree( preedit_data_bc ); } ! } } ! } ! for(p = vl; p->name != NULL; p++) { ! if(strcmp(p->name, XNArea)==0) { ! if(im_preedit_flag) { ! if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { ! *return_name = p->name; ! return(False); } + p_rect->x = preedit_data->Area.x; + p_rect->y = preedit_data->Area.y; + p_rect->width = preedit_data->Area.width; + p_rect->height = preedit_data->Area.height; + } else { + if(XIMP_CHK_PREAREAMASK(ic)) { + if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { + *return_name = p->name; + return(False); + } + p_rect->x = ic->core.preedit_attr.area.x; + p_rect->y = ic->core.preedit_attr.area.y; + p_rect->width = ic->core.preedit_attr.area.width; + p_rect->height = ic->core.preedit_attr.area.height; + } else { + *return_name = p->name; + return(False); + } + } + *((XRectangle **)(p->value)) = p_rect; + } else if(strcmp(p->name, XNAreaNeeded)==0) { + if(im_preedit_flag) { + if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { + *return_name = p->name; + return(False); + } + p_rect->x = p_rect->y = 0; + p_rect->width = preedit_data->AreaNeeded.width; + p_rect->height = preedit_data->AreaNeeded.height; + } else { + if(XIMP_CHK_PREAREANEEDMASK(ic)) { + if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { + *return_name = p->name; + return(False); + } + p_rect->x = p_rect->y = 0; + p_rect->width = ic->core.preedit_attr.area_needed.width; + p_rect->height = ic->core.preedit_attr.area_needed.height; + } else { + *return_name = p->name; + return(False); + } + } + *((XRectangle **)(p->value)) = p_rect; + } else if(strcmp(p->name, XNSpotLocation)==0) { + if(im_preedit_flag) { + if((p_point = (XPoint *)Xmalloc(sizeof(XPoint))) == NULL) { + *return_name = p->name; + return(False); + } + p_point->x = preedit_data->SpotLocation.x; + p_point->y = preedit_data->SpotLocation.y; + } else { + if(XIMP_CHK_PRESPOTLMASK(ic)) { + if((p_point = (XPoint *)Xmalloc(sizeof(XPoint))) == NULL) { + *return_name = p->name; + return(False); + } + p_point->x = ic->core.preedit_attr.spot_location.x; + p_point->y = ic->core.preedit_attr.spot_location.y; + } else { + *return_name = p->name; + return(False); + } + } + *((XPoint **)(p->value)) = p_point; + } else if(strcmp(p->name, XNColormap)==0) { + if(im_preedit_flag) { + *((Colormap *)(p->value)) = preedit_data->Colormap; + } else { + if(XIMP_CHK_PRECOLORMAPMASK(ic)) { + *((Colormap *)(p->value)) = ic->core.preedit_attr.colormap; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNStdColormap)==0) { + if(im_preedit_flag) { + *((Atom *)(p->value)) = preedit_data->StdColormap; + } else { + if(XIMP_CHK_PRESTDCOLORMAPMASK(ic)) + *((Atom *)(p->value)) = ic->core.preedit_attr.std_colormap; + else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNBackground)==0) { + if(im_preedit_flag) { + *((unsigned long *)(p->value)) = preedit_data->Background; + } else { + if(XIMP_CHK_PREBGMASK(ic)) { + *((unsigned long *)(p->value)) = ic->core.preedit_attr.background; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNForeground)==0) { + if(im_preedit_flag) { + *((unsigned long *)(p->value)) = preedit_data->Foreground; + } else { + if(XIMP_CHK_PREFGMASK(ic)) { + *((unsigned long *)(p->value)) = ic->core.preedit_attr.foreground; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNBackgroundPixmap)==0) { + if(im_preedit_flag) { + *((Pixmap *)(p->value)) = preedit_data->Bg_Pixmap; + } else { + if(XIMP_CHK_PREBGPIXMAPMASK(ic)) { + *((Pixmap *)(p->value)) = ic->core.preedit_attr.background_pixmap; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNFontSet)==0) { + if(XIMP_CHK_PREFONTMASK(ic)) { + *((XFontSet *)(p->value)) = ic->core.preedit_attr.fontset; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNLineSpace)==0) { + if(im_preedit_flag) { + *((int *)(p->value)) = preedit_data->LineSpacing; + } else { + if(XIMP_CHK_PRELINESPMASK(ic)) { + *((int *)(p->value)) = ic->core.preedit_attr.line_space; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNCursor)==0) { + if(im_preedit_flag) { + *((Cursor *)(p->value)) = preedit_data->Cursor; + } else { + if(XIMP_CHK_PRECURSORMASK(ic)) { + *((Cursor *)(p->value)) = ic->core.preedit_attr.cursor; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNPreeditStartCallback)==0) { + if((int)ic->core.preedit_attr.callbacks.start.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.preedit_attr.callbacks.start.client_data; + p_callback->callback = + ic->core.preedit_attr.callbacks.start.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNPreeditDrawCallback)==0) { + if((int)ic->core.preedit_attr.callbacks.draw.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.preedit_attr.callbacks.draw.client_data; + p_callback->callback = + ic->core.preedit_attr.callbacks.draw.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNPreeditDoneCallback)==0) { + if((int)ic->core.preedit_attr.callbacks.done.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.preedit_attr.callbacks.done.client_data; + p_callback->callback = + ic->core.preedit_attr.callbacks.done.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNPreeditCaretCallback)==0) { + if((int)ic->core.preedit_attr.callbacks.caret.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.preedit_attr.callbacks.caret.client_data; + p_callback->callback = + ic->core.preedit_attr.callbacks.caret.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } } ! } ! if( preedit_data ) ! XFree(preedit_data); ! return(True); } static Bool *************** *** 412,665 **** XIMArg *vl; char **return_name; { ! XIMArg *p; ! XRectangle *p_rect; ! unsigned long mask; ! int im_status_flag = 0; ! Ximp_StatusPropRec *status_data = NULL; ! XIMCallback *p_callback; ! if(((Ximp_XIM)ic->core.im)->ximp_impart->connectserver) { ! for(mask = 0, p = vl; p->name != NULL; p++) { ! if(strcmp(p->name, XNArea)==0) ! mask |= XIMP_STS_AREA_MASK; ! else if(strcmp(p->name, XNAreaNeeded)==0) ! mask |= XIMP_STS_AREANEED_MASK; ! else if(strcmp(p->name, XNColormap)==0) ! mask |= XIMP_STS_COLORMAP_MASK; ! else if(strcmp(p->name, XNStdColormap)==0) ! mask |= XIMP_STS_COLORMAP_MASK; ! else if(strcmp(p->name, XNBackground)==0) ! mask |= XIMP_STS_BG_MASK; ! else if(strcmp(p->name, XNForeground)==0) ! mask |= XIMP_STS_FG_MASK; ! else if(strcmp(p->name, XNBackgroundPixmap)==0) ! mask |= XIMP_STS_BGPIXMAP_MASK; ! else if(strcmp(p->name, XNLineSpace)==0) ! mask |= XIMP_STS_LINESP_MASK; ! else if(strcmp(p->name, XNCursor)==0) ! mask |= XIMP_STS_CURSOR_MASK; } ! if(mask) { ! status_data = (Ximp_StatusPropRec *)_Ximp_GetRequestIM(ic, mask, ! ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id, ! ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id); ! if(status_data != (Ximp_StatusPropRec *)NULL) ! im_status_flag = 1; ! } } ! for(p = vl; p->name != NULL; p++) { ! if(strcmp(p->name, XNArea)==0) { ! if(im_status_flag) { ! if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_rect->x = status_data->Area.x; ! p_rect->y = status_data->Area.y; ! p_rect->width = status_data->Area.width; ! p_rect->height = status_data->Area.height; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_STS_AREA_MASK) { ! if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_rect->x = ic->core.status_attr.area.x; ! p_rect->y = ic->core.status_attr.area.y; ! p_rect->width = ic->core.status_attr.area.width; ! p_rect->height = ic->core.status_attr.area.height; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! *((XRectangle **)(p->value)) = p_rect; ! } else if(strcmp(p->name, XNAreaNeeded)==0) { ! if(im_status_flag) { ! if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_rect->x = p_rect->y = 0; ! p_rect->width = status_data->AreaNeeded.width; ! p_rect->height = status_data->AreaNeeded.height; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_STS_AREANEED_MASK) { ! if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_rect->x = p_rect->y = 0; ! p_rect->width = ic->core.status_attr.area_needed.width; ! p_rect->height = ic->core.status_attr.area_needed.height; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! *((XRectangle **)(p->value)) = p_rect; ! } else if( strcmp(p->name, XNColormap)==0 ! || strcmp(p->name, XNStdColormap)==0) { ! if(im_status_flag) { ! *((Colormap *)(p->value)) = status_data->Colormap; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_STS_COLORMAP_MASK) { ! *((Colormap *)(p->value)) = ic->core.status_attr.colormap; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNBackground)==0) { ! if(im_status_flag) { ! *((unsigned long *)(p->value)) = status_data->Background; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_STS_BG_MASK) { ! *((unsigned long *)(p->value)) = ic->core.status_attr.background; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNForeground)==0) { ! if(im_status_flag) { ! *((unsigned long *)(p->value)) = status_data->Foreground; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_STS_FG_MASK) { ! *((unsigned long *)(p->value)) = ic->core.status_attr.foreground; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNBackgroundPixmap)==0) { ! if(im_status_flag) { ! *((Pixmap *)(p->value)) = status_data->Bg_Pixmap; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_STS_BGPIXMAP_MASK) { ! *((Pixmap *)(p->value)) = ic->core.status_attr.background_pixmap; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNFontSet)==0) { ! if(ic->ximp_icpart->proto_mask & XIMP_STS_FONT_MASK) { ! *((XFontSet *)(p->value)) = ic->core.status_attr.fontset; ! } else { ! *return_name = p->name; ! return(False); ! } ! } else if(strcmp(p->name, XNLineSpace)==0) { ! if(im_status_flag) { ! *((int *)(p->value)) = status_data->LineSpacing; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_STS_LINESP_MASK) { ! *((int *)(p->value)) = ic->core.status_attr.line_space; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNCursor)==0) { ! if(im_status_flag) { ! *((Cursor *)(p->value)) = status_data->Cursor; ! } else { ! if(ic->ximp_icpart->proto_mask & XIMP_STS_CURSOR_MASK) { ! *((Cursor *)(p->value)) = ic->core.status_attr.cursor; ! } else { ! *return_name = p->name; ! return(False); ! } ! } ! } else if(strcmp(p->name, XNStatusStartCallback)==0) { ! if((int)ic->core.status_attr.callbacks.start.callback) { ! if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_callback->client_data = ! ic->core.status_attr.callbacks.start.client_data; ! p_callback->callback = ! ic->core.status_attr.callbacks.start.callback; ! *((XIMCallback **)(p->value)) = p_callback; ! } else { ! *return_name = p->name; ! return(False); ! } ! } else if(strcmp(p->name, XNStatusDrawCallback)==0) { ! if((int)ic->core.status_attr.callbacks.draw.callback) { ! if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_callback->client_data = ! ic->core.status_attr.callbacks.draw.client_data; ! p_callback->callback = ! ic->core.status_attr.callbacks.draw.callback; ! *((XIMCallback **)(p->value)) = p_callback; ! } else { ! *return_name = p->name; ! return(False); ! } ! } else if(strcmp(p->name, XNStatusDoneCallback)==0) { ! if((int)ic->core.status_attr.callbacks.done.callback) { ! if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { ! *return_name = p->name; ! return(False); ! } ! p_callback->client_data = ! ic->core.status_attr.callbacks.done.client_data; ! p_callback->callback = ! ic->core.status_attr.callbacks.done.callback; ! *((XIMCallback **)(p->value)) = p_callback; ! } else { ! *return_name = p->name; ! return(False); ! } } } ! if( status_data ) ! XFree(status_data); ! return(True); ! } ! ! static XPointer ! _Ximp_GetRequestIM(ic, mask, get_atom_id, atom_id) ! Ximp_XIC ic; ! unsigned long mask; ! Atom get_atom_id, atom_id; ! { ! XEvent event; ! Atom actual_type_ret; ! int actual_format_ret; ! unsigned long nitems_ret; ! unsigned long bytes_after_ret; ! unsigned char *data; ! XimpCMPredicateArgRec Arg; ! ! if(ic->ximp_icpart->icid == (ICID)NULL) ! return(NULL); ! if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) ! return(NULL); ! ! _Ximp_IM_SendMessage(ic, XIMP_GETVALUE, mask, NULL, NULL); ! Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; ! Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; ! Arg.protocol = XIMP_GETVALUE_RETURN; ! Arg.icid = ic->ximp_icpart->icid; ! if( !_XimpIfEvent( ic, &event, _Ximp_CMPredicate, (XPointer)&Arg ) ) ! return( NULL ); ! ! XGetWindowProperty(ic->core.im->core.display, ! ic->core.client_window, ! get_atom_id, 0L, 1000000L, True, atom_id, ! &actual_type_ret, &actual_format_ret, &nitems_ret, ! &bytes_after_ret, &data); ! ! if(actual_format_ret == 0 || nitems_ret == 0) ! return(NULL); ! return((XPointer)data); } --- 486,732 ---- XIMArg *vl; char **return_name; { ! XIMArg *p; ! XRectangle *p_rect; ! unsigned long mask; ! int im_status_flag = 0; ! Ximp_StatusPropRec4 *status_data = NULL; ! Ximp_StatusPropRec3 *status_data_bc = NULL; ! XIMCallback *p_callback; ! if(IS_IC_CONNECTED(ic)){ ! for(mask = 0, p = vl; p->name != NULL; p++) { ! if(strcmp(p->name, XNArea)==0) ! mask |= XIMP_STS_AREA_MASK(ic); ! else if(strcmp(p->name, XNAreaNeeded)==0) ! mask |= XIMP_STS_AREANEED_MASK(ic); ! else if(strcmp(p->name, XNColormap)==0) ! mask |= XIMP_STS_COLORMAP_MASK(ic); ! else if(strcmp(p->name, XNStdColormap)==0) ! mask |= XIMP_STS_STD_COLORMAP_MASK(ic); ! else if(strcmp(p->name, XNBackground)==0) ! mask |= XIMP_STS_BG_MASK(ic); ! else if(strcmp(p->name, XNForeground)==0) ! mask |= XIMP_STS_FG_MASK(ic); ! else if(strcmp(p->name, XNBackgroundPixmap)==0) ! mask |= XIMP_STS_BGPIXMAP_MASK(ic); ! else if(strcmp(p->name, XNLineSpace)==0) ! mask |= XIMP_STS_LINESP_MASK(ic); ! else if(strcmp(p->name, XNCursor)==0) ! mask |= XIMP_STS_CURSOR_MASK(ic); ! } ! if(mask) { ! status_data = (Ximp_StatusPropRec4 *)_Ximp_GetRequestIM(ic, mask, ! ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id, ! ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id); ! if(status_data != (Ximp_StatusPropRec4 *)NULL) { ! im_status_flag = 1; ! if( !ISXimp4(ic) ) { ! status_data_bc = (Ximp_StatusPropRec3 *)status_data; ! if( (status_data = (Ximp_StatusPropRec4 *)Xmalloc(sizeof(Ximp_StatusPropRec4))) == NULL ) { ! im_status_flag = 0; ! } ! else { ! status_data->Area = status_data_bc->Area; ! status_data->AreaNeeded = status_data_bc->AreaNeeded; ! status_data->Colormap = status_data_bc->Colormap; ! status_data->StdColormap = status_data_bc->Colormap; ! status_data->Foreground = status_data_bc->Foreground; ! status_data->Background = status_data_bc->Background; ! status_data->Bg_Pixmap = status_data_bc->Bg_Pixmap; ! status_data->LineSpacing = status_data_bc->LineSpacing; ! status_data->Cursor = status_data_bc->Cursor; ! status_data->window = status_data_bc->window; ! } ! XFree( status_data_bc ); } ! } } + } ! for(p = vl; p->name != NULL; p++) { ! if(strcmp(p->name, XNArea)==0) { ! if(im_status_flag) { ! if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { ! *return_name = p->name; ! return(False); } + p_rect->x = status_data->Area.x; + p_rect->y = status_data->Area.y; + p_rect->width = status_data->Area.width; + p_rect->height = status_data->Area.height; + } else { + if(XIMP_CHK_STSAREAMASK(ic)) { + if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { + *return_name = p->name; + return(False); + } + p_rect->x = ic->core.status_attr.area.x; + p_rect->y = ic->core.status_attr.area.y; + p_rect->width = ic->core.status_attr.area.width; + p_rect->height = ic->core.status_attr.area.height; + } else { + *return_name = p->name; + return(False); + } + } + *((XRectangle **)(p->value)) = p_rect; + } else if(strcmp(p->name, XNAreaNeeded)==0) { + if(im_status_flag) { + if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { + *return_name = p->name; + return(False); + } + p_rect->x = p_rect->y = 0; + p_rect->width = status_data->AreaNeeded.width; + p_rect->height = status_data->AreaNeeded.height; + } else { + if(XIMP_CHK_STSAREANEEDMASK(ic)) { + if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { + *return_name = p->name; + return(False); + } + p_rect->x = p_rect->y = 0; + p_rect->width = ic->core.status_attr.area_needed.width; + p_rect->height = ic->core.status_attr.area_needed.height; + } else { + *return_name = p->name; + return(False); + } + } + *((XRectangle **)(p->value)) = p_rect; + } else if(strcmp(p->name, XNColormap)==0) { + if(im_status_flag) { + *((Colormap *)(p->value)) = status_data->Colormap; + } else { + if(XIMP_CHK_STSCOLORMAPMASK(ic)) { + *((Colormap *)(p->value)) = ic->core.status_attr.colormap; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNStdColormap)==0) { + if(im_status_flag) { + *((Atom *)(p->value)) = status_data->StdColormap; + } else { + if(XIMP_STS_STD_COLORMAP_MASK(ic)) { + *((Atom *)(p->value)) = ic->core.status_attr.std_colormap; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNBackground)==0) { + if(im_status_flag) { + *((unsigned long *)(p->value)) = status_data->Background; + } else { + if(XIMP_CHK_STSBGMASK(ic)) { + *((unsigned long *)(p->value)) = ic->core.status_attr.background; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNForeground)==0) { + if(im_status_flag) { + *((unsigned long *)(p->value)) = status_data->Foreground; + } else { + if(XIMP_CHK_STSFGMASK(ic)) { + *((unsigned long *)(p->value)) = ic->core.status_attr.foreground; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNBackgroundPixmap)==0) { + if(im_status_flag) { + *((Pixmap *)(p->value)) = status_data->Bg_Pixmap; + } else { + if(XIMP_CHK_STSBGPIXMAPMASK(ic)) { + *((Pixmap *)(p->value)) = ic->core.status_attr.background_pixmap; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNFontSet)==0) { + if(XIMP_CHK_STSFONTMASK(ic)) { + *((XFontSet *)(p->value)) = ic->core.status_attr.fontset; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNLineSpace)==0) { + if(im_status_flag) { + *((int *)(p->value)) = status_data->LineSpacing; + } else { + if(XIMP_CHK_STSLINESPMASK(ic)) { + *((int *)(p->value)) = ic->core.status_attr.line_space; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNCursor)==0) { + if(im_status_flag) { + *((Cursor *)(p->value)) = status_data->Cursor; + } else { + if(XIMP_CHK_STSCURSORMASK(ic)) { + *((Cursor *)(p->value)) = ic->core.status_attr.cursor; + } else { + *return_name = p->name; + return(False); + } + } + } else if(strcmp(p->name, XNStatusStartCallback)==0) { + if((int)ic->core.status_attr.callbacks.start.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.status_attr.callbacks.start.client_data; + p_callback->callback = + ic->core.status_attr.callbacks.start.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNStatusDrawCallback)==0) { + if((int)ic->core.status_attr.callbacks.draw.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.status_attr.callbacks.draw.client_data; + p_callback->callback = + ic->core.status_attr.callbacks.draw.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNStatusDoneCallback)==0) { + if((int)ic->core.status_attr.callbacks.done.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.status_attr.callbacks.done.client_data; + p_callback->callback = + ic->core.status_attr.callbacks.done.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } } ! } ! if( status_data ) ! XFree(status_data); ! return(True); } *** /tmp/d03849 Tue Mar 9 09:21:46 1993 --- mit/lib/X/Ximp/XimpICS.c Tue Mar 9 09:21:44 1993 *************** *** 1,38 **** ! /* $XConsortium: XimpICS.c,v 1.4 92/07/29 10:16:04 rws Exp $ */ /****************************************************************** ! Copyright 1991, 1992 by FUJITSU LIMITED ! Copyright 1991, 1992 by Sony Corporation Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, ! provided that the above copyright notice appear in all copies and ! that both that copyright notice and this permission notice appear ! in supporting documentation, and that the name of FUJITSU LIMITED ! and Sony Corporaion not be used in advertising or publicity ! pertaining to distribution of the software without specific, ! written prior permission. ! FUJITSU LIMITED and Sony Corporaion make no representations about ! the suitability of this software for any purpose. It is provided ! "as is" without express or implied warranty. ! FUJITSU LIMITED AND SONY CORPORATION DISCLAIM ALL WARRANTIES WITH ! REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND ! SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL ! DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA ! OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ! TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE ! OR PERFORMANCE OF THIS SOFTWARE. ! Author: Takashi Fujiwara FUJITSU LIMITED ! Makoto Wakamatsu Sony Corporation ******************************************************************/ ! #define NEED_EVENTS #include "Xlibint.h" #include "Xlcint.h" #include "Ximplc.h" --- 1,41 ---- ! /* $XConsortium: XimpICS.c,v 1.5 92/10/19 19:24:39 rws Exp $ */ /****************************************************************** ! Copyright 1991, 1992 by FUJITSU LIMITED. ! Copyright 1991, 1992 by Sun Microsystems, Inc. ! Copyright 1991, 1992 by Sony Corporation Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, ! provided that the above copyright notice appear in all copies and that ! both that copyright notice and this permission notice appear in ! supporting documentation, and that the name of FUJITSU LIMITED, Sun ! Microsystems, Inc. and Sony Corporation not be used in advertising ! or publicity pertaining to distribution of the software without ! specific, written prior permission. ! FUJITSU LIMITED , Sun Microsystems, Inc. and Sony Corporation make no ! representations about the suitability of this software for any ! purpose. It is provided "as is" without express or implied warranty. ! FUJITSU LIMITED, SUN MICROSYSTEMS, INC. AND SONY CORPORATION DISCLAIM ! ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED ! WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU ! LIMITED, SUN MICROSYSTEMS, INC. AND SONY CORPORATION BE LIABLE FOR ANY ! SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ! RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF ! CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN ! CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ! Author: Takashi Fujiwara FUJITSU LIMITED ! Hideki Hiura Sun Microsystems, Inc. ! Makoto Wakamatsu Sony Corporaion ******************************************************************/ ! #define NEED_EVENTS #include "Xlibint.h" #include "Xlcint.h" + #include "Xutil.h" #include "Ximplc.h" *************** *** 41,58 **** extern void _Ximp_SetValue_Resource(); extern Bool _Ximp_SetICExtension(); ! extern void _Ximp_SetFocusWindow(); extern void _Ximp_SetPreeditAtr(); extern void _Ximp_SetPreeditFont(); extern void _Ximp_SetStatusAtr(); extern void _Ximp_SetStatusFont(); extern void _Ximp_IM_SendMessage(); extern Bool _Ximp_XimFilter_Keypress(); static Bool _Ximp_PreSetAttributes(); static Bool _Ximp_StatusSetAttributes(); - static Bool _Ximp_PNPredicate( d, ev, arg0 ) Display *d; --- 44,66 ---- extern void _Ximp_SetValue_Resource(); extern Bool _Ximp_SetICExtension(); ! extern void _Ximp_SetFocusWindowProp(); ! extern void _Ximp_SetFocusWindowFilter(); extern void _Ximp_SetPreeditAtr(); extern void _Ximp_SetPreeditFont(); extern void _Ximp_SetStatusAtr(); extern void _Ximp_SetStatusFont(); extern void _Ximp_IM_SendMessage(); + extern void _Ximp_ProcError(); + extern Bool _Ximp_CMPredicate32(); extern Bool _Ximp_XimFilter_Keypress(); + extern Bool _Ximp_XimFilter_Keyrelease(); + extern Bool _Ximp_XimFilter_Client(); + extern void _Ximp_GetFocusWindowSelectMask(); static Bool _Ximp_PreSetAttributes(); static Bool _Ximp_StatusSetAttributes(); static Bool _Ximp_PNPredicate( d, ev, arg0 ) Display *d; *************** *** 67,81 **** ev->xproperty.state == PropertyDelete ) { return(True); } ! } ! else if( ev->type == ClientMessage ) { if( ev->xclient.message_type == arg->type && ev->xclient.format == 32 && ev->xclient.data.l[1] == arg->icid && ! ev->xclient.data.l[0] == XIMP_ERROR ) return( True ); ! } ! else if( ev->type == DestroyNotify ) { if( ev->xdestroywindow.window == arg->owner ) { return( True ); } --- 75,87 ---- ev->xproperty.state == PropertyDelete ) { return(True); } ! } else if( ev->type == ClientMessage ) { if( ev->xclient.message_type == arg->type && ev->xclient.format == 32 && ev->xclient.data.l[1] == arg->icid && ! ISXIMP_ERROR(ev) ) return( True ); ! } else if( ev->type == DestroyNotify ) { if( ev->xdestroywindow.window == arg->owner ) { return( True ); } *************** *** 125,525 **** char * _Ximp_SetICValues(ic, values) ! Ximp_XIC ic; ! XIMArg *values; ! { ! XIM im; ! char *ret; ! int change_mask = 0; ! if((ret = _Ximp_SetICValueData(ic, values, XIMP_SET_IC, &change_mask))) ! return(ret); ! if( (ic->ximp_icpart->value_mask & XIMP_RES_NAME) ! || (ic->ximp_icpart->value_mask & XIMP_RES_CLASS) ) ! _Ximp_SetValue_Resource(ic, &change_mask); ! if(ic->ximp_icpart->icid == NULL) { ! if(change_mask & XIMP_PROP_FOCUS) { ! if(ic->ximp_icpart->filter_mode & 0x1) { ! _XUnregisterFilter (ic->core.im->core.display, ! ic->ximp_icpart->back_focus_win, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! } ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyPress, KeyPress, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! ic->ximp_icpart->filter_mode |= 0x1; ! } ! return(ret); ! } ! if(ic->core.input_style & XIMPreeditPosition) { ! if(change_mask == XIMP_PRE_SPOTL_MASK) { ! if(ic->ximp_icpart->input_mode) ! _Ximp_IM_SendMessage(ic, XIMP_MOVE, ! ic->ximp_icpart->preedit_attr.SpotLocation.x, ! ic->ximp_icpart->preedit_attr.SpotLocation.y, ! NULL); ! return(ret); ! } } ! if(change_mask & XIMP_PROP_FOCUS) ! _Ximp_SetFocusWindow(ic); ! if(!( (ic->core.input_style & XIMPreeditCallbacks) ! || (ic->core.input_style & XIMPreeditNone) ) ) { ! if(change_mask & XIMP_PROP_PREEDIT) ! _Ximp_SetPreeditAtr(ic); ! if(change_mask & XIMP_PROP_PREFONT) ! _Ximp_SetPreeditFont(ic); ! } ! else { ! change_mask &= ~(XIMP_PROP_PREEDIT | XIMP_PROP_PREFONT); ! } ! if(!( (ic->core.input_style & XIMStatusCallbacks) ! || (ic->core.input_style & XIMStatusNone) ) ) { ! if(change_mask & XIMP_PROP_STATUS) ! _Ximp_SetStatusAtr(ic); ! if(change_mask & XIMP_PROP_STSFONT) ! _Ximp_SetStatusFont(ic); ! } ! else { ! change_mask &= ~(XIMP_PROP_STATUS | XIMP_PROP_STSFONT); ! } ! if(change_mask) { ! XWindowAttributes war; ! long mask; ! XGetWindowAttributes( ic->core.im->core.display, ! ic->core.client_window, &war ); ! XSelectInput( ic->core.im->core.display, ic->core.client_window, ! war.your_event_mask | PropertyChangeMask ); ! _Ximp_IM_SendMessage(ic, XIMP_SETVALUE, change_mask, NULL, NULL); ! if( change_mask & XIMP_PROP_FOCUS ) ! if( !_XimpPNIfEvent( ic, ((Ximp_XIM)ic->core.im)->ximp_impart->focus_win_id ) ) ! change_mask = 0; ! if( change_mask & XIMP_PROP_PREEDIT ) ! if( !_XimpPNIfEvent( ic, ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id ) ) ! change_mask = 0; ! if( change_mask & XIMP_PROP_PREFONT ) ! if( !_XimpPNIfEvent( ic, ((Ximp_XIM)ic->core.im)->ximp_impart->preeditfont_id ) ) ! change_mask = 0; ! if( change_mask & XIMP_PROP_STATUS ) ! if( !_XimpPNIfEvent( ic, ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id ) ) ! change_mask = 0; ! if( change_mask & XIMP_PROP_STSFONT ) ! !_XimpPNIfEvent( ic, ((Ximp_XIM)ic->core.im)->ximp_impart->statusfont_id ); ! XSelectInput( ic->core.im->core.display, ic->core.client_window, ! war.your_event_mask ); } return(ret); } char * _Ximp_SetICValueData(ic, values, mode, change_mask) ! Ximp_XIC ic; ! XIMArg *values; ! int mode; ! int *change_mask; ! { ! XIMArg *p; ! char *return_name = NULL; ! for(p = values; p->name != NULL; p++) { ! if(strcmp(p->name, XNInputStyle) == 0) { ! if(mode == XIMP_CREATE_IC) { ! ic->core.input_style = (XIMStyle)p->value; ! ic->ximp_icpart->value_mask |= XIMP_INPUT_STYLE; ! } ! else ! ; /* Currently Fixed value */ ! } ! else if(strcmp(p->name, XNClientWindow)==0) { ! if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { ! if(mode == XIMP_SET_IC && (ic->ximp_icpart->icid)) { ! long icid_old, icid_new; ! Window client_window; ! icid_old = ic->ximp_icpart->icid; ! client_window = ic->core.client_window; ! ic->ximp_icpart->value_mask |= XIMP_CLIENT_WIN; ! ic->core.client_window = (Window)p->value; ! if(_Ximp_SetOpenXIMP(ic, mode) == False) { ! return_name = p->name; ! ic->ximp_icpart->value_mask &= ~XIMP_CLIENT_WIN; ! ic->core.client_window = client_window; ! break; ! } ! icid_new = ic->ximp_icpart->icid; ! ic->ximp_icpart->icid = icid_old; ! _Ximp_IM_SendMessage(ic, XIMP_DESTROY, NULL, NULL, NULL); ! ic->ximp_icpart->icid = icid_new; ! XDestroyWindow(ic->core.im->core.display, ! client_window); ! *change_mask = NULL; ! } ! else { /* XIMP_CREATE_IC | (XIMP_SET_IC && XIMP_START_IC) */ ! ic->core.client_window = (Window)p->value; ! ic->ximp_icpart->value_mask |= XIMP_CLIENT_WIN; ! if(!(ic->ximp_icpart->proto_mask & XIMP_FOCUS_WIN_MASK)) { ! ic->core.focus_window = ic->core.client_window; ! ic->ximp_icpart->proto_mask |= XIMP_FOCUS_WIN_MASK; ! } ! } ! } ! else { ! return_name = p->name; ! break; /* Can't change this value */ ! } } ! else if(strcmp(p->name, XNFocusWindow)==0) { ! if(mode == XIMP_SET_IC && ic->ximp_icpart->input_mode) { ! Window new_focus_window = (Window)p->value; ! unsigned long dummy_mask; ! XWindowAttributes wattr; ! XSelectInput(ic->core.im->core.display, ! ic->core.focus_window, ! ic->ximp_icpart->back_mask); ! XGetWindowAttributes(ic->core.im->core.display, ! new_focus_window, ! &wattr); ! dummy_mask = wattr.your_event_mask; ! ic->ximp_icpart->back_mask = dummy_mask; ! if(ic->ximp_icpart->is_bep_mode == XIMP_FRONTEND) { ! dummy_mask &= ~(KeyPressMask | KeyReleaseMask); ! } ! else { ! dummy_mask &= ~(KeyReleaseMask); ! } ! XSelectInput(ic->core.im->core.display, ! new_focus_window, ! dummy_mask); ! } ! ic->ximp_icpart->back_focus_win = ic->core.focus_window; ! ic->core.focus_window = (Window)p->value; ! ic->ximp_icpart->proto_mask |= XIMP_FOCUS_WIN_MASK; ! *change_mask |= XIMP_FOCUS_WIN_MASK; } ! else if(strcmp(p->name, XNResourceName)==0) { ! ic->core.im->core.res_name = (char *)p->value; ! ic->ximp_icpart->value_mask |= XIMP_RES_NAME; ! } ! else if(strcmp(p->name, XNResourceClass)==0) { ! ic->core.im->core.res_class = (char *)p->value; ! ic->ximp_icpart->value_mask |= XIMP_RES_CLASS; ! } ! else if(strcmp(p->name, XNGeometryCallback)==0) { ! ic->core.geometry_callback.client_data = ! ((XIMCallback *)p->value)->client_data; ! ic->core.geometry_callback.callback = ! ((XIMCallback *)p->value)->callback; ! ic->ximp_icpart->value_mask |= XIMP_GEOMETRY_CB; ! } ! else if(strcmp(p->name, XNPreeditAttributes)==0) { ! if( _Ximp_PreSetAttributes(ic, ! &(ic->ximp_icpart->preedit_attr), ! p->value, mode, change_mask, ! return_name) == False ) ! break; ! } ! else if(strcmp(p->name, XNStatusAttributes)==0) { ! if( _Ximp_StatusSetAttributes(ic, ! &(ic->ximp_icpart->status_attr), ! p->value, mode, change_mask, ! return_name) == False ) ! break; ! } ! else { ! if( _Ximp_SetICExtension(ic, p->name, p->value, mode) == False ) { ! return_name = p->name; ! break; ! } ! } } ! return(return_name); } ! static Bool _Ximp_PreSetAttributes(ic, attr, vl, mode, change_mask, return_name) ! Ximp_XIC ic; ! Ximp_PreeditPropRec *attr; ! XIMArg *vl; ! int mode; ! int *change_mask; ! char *return_name; ! { ! XIMArg *p; ! Colormap colormap_ret; ! int list_ret; ! XFontStruct **struct_list; ! char **name_list; ! int i, len; ! char *tmp; ! ! for(p = vl; p->name != NULL; p++) { ! if(strcmp(p->name, XNArea)==0) { ! ic->core.preedit_attr.area.x = ((XRectangle *)p->value)->x; ! ic->core.preedit_attr.area.y = ((XRectangle *)p->value)->y; ! ic->core.preedit_attr.area.width = ((XRectangle *)p->value)->width; ! ic->core.preedit_attr.area.height = ((XRectangle *)p->value)->height; ! attr->Area.x = ic->core.preedit_attr.area.x; ! attr->Area.y = ic->core.preedit_attr.area.y; ! attr->Area.width = ic->core.preedit_attr.area.width; ! attr->Area.height = ic->core.preedit_attr.area.height; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_AREA_MASK; ! *change_mask |= XIMP_PRE_AREA_MASK; ! } ! else if(strcmp(p->name, XNAreaNeeded)==0) { ! ic->core.preedit_attr.area_needed.width = ((XRectangle *)p->value)->width; ! ic->core.preedit_attr.area_needed.height = ((XRectangle *)p->value)->height; ! attr->AreaNeeded.width = ic->core.preedit_attr.area_needed.width; ! attr->AreaNeeded.height = ic->core.preedit_attr.area_needed.height; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_AREANEED_MASK; ! *change_mask |= XIMP_PRE_AREANEED_MASK; ! } ! else if(strcmp(p->name, XNSpotLocation)==0) { ! ic->core.preedit_attr.spot_location.x = ((XPoint *)p->value)->x; ! ic->core.preedit_attr.spot_location.y = ((XPoint *)p->value)->y; ! attr->SpotLocation.x = ic->core.preedit_attr.spot_location.x; ! attr->SpotLocation.y = ic->core.preedit_attr.spot_location.y; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_SPOTL_MASK; ! *change_mask |= XIMP_PRE_SPOTL_MASK; ! } ! else if(strcmp(p->name, XNColormap)==0) { ! ic->core.preedit_attr.colormap = (Colormap)p->value; ! attr->Colormap = ic->core.preedit_attr.colormap; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_COLORMAP_MASK; ! *change_mask |= XIMP_PRE_COLORMAP_MASK; ! } ! else if(strcmp(p->name, XNStdColormap)==0) { ! if( XGetStandardColormap(ic->core.im->core.display, ! ic->core.focus_window, ! &colormap_ret, (Atom)p->value) != 0) { ! ic->core.preedit_attr.colormap = colormap_ret; ! attr->Colormap = ic->core.preedit_attr.colormap; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_COLORMAP_MASK; ! *change_mask |= XIMP_PRE_COLORMAP_MASK; ! } ! else { ! return_name = p->name; ! return(False); ! } ! } ! else if(strcmp(p->name, XNBackground)==0) { ! ic->core.preedit_attr.background = (unsigned long)p->value; ! attr->Background = ic->core.preedit_attr.background; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_BG_MASK; ! *change_mask |= XIMP_PRE_BG_MASK; ! } ! else if(strcmp(p->name, XNForeground)==0) { ! ic->core.preedit_attr.foreground = (unsigned long)p->value; ! attr->Foreground = ic->core.preedit_attr.foreground; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_FG_MASK; ! *change_mask |= XIMP_PRE_FG_MASK; ! } ! else if(strcmp(p->name, XNBackgroundPixmap)==0) { ! ic->core.preedit_attr.background_pixmap = (Pixmap)p->value; ! attr->Bg_Pixmap = ic->core.preedit_attr.background_pixmap; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_BGPIXMAP_MASK; ! *change_mask |= XIMP_PRE_BGPIXMAP_MASK; ! } ! else if(strcmp(p->name, XNFontSet)==0) { ! ic->core.preedit_attr.fontset = (XFontSet)p->value; ! if(p->value != NULL) { ! if(ic->ximp_icpart->preedit_font) ! Xfree(ic->ximp_icpart->preedit_font); ! list_ret = XFontsOfFontSet( ! ic->core.preedit_attr.fontset, ! &struct_list, &name_list); ! for(i = 0, len = 0; i < list_ret; i++) { ! len += strlen(name_list[i]); ! } ! if( (tmp = Xmalloc(len + i + 1)) == NULL ) { ! return_name = p->name; ! return( False ); ! } ! tmp[0] = NULL; ! for(i = 0; i < list_ret; i++) { ! strcat(tmp, name_list[i]); ! strcat(tmp, ","); ! } ! tmp[len + i - 1] = NULL; ! ic->ximp_icpart->preedit_font = tmp; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_FONT_MASK; ! *change_mask |= XIMP_PRE_FONT_MASK; ! } ! else { ! return_name = p->name; ! return(False); ! } ! } ! else if(strcmp(p->name, XNLineSpace)==0) { ! ic->core.preedit_attr.line_space = (long)p->value; ! attr->LineSpacing = ic->core.preedit_attr.line_space; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_LINESP_MASK; ! *change_mask |= XIMP_PRE_LINESP_MASK; ! } ! else if(strcmp(p->name, XNCursor)==0) { ! ic->core.preedit_attr.cursor = (Cursor)p->value; ! attr->Cursor = ic->core.preedit_attr.cursor; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_CURSOR_MASK; ! *change_mask |= XIMP_PRE_CURSOR_MASK; ! } ! else if(strcmp(p->name, XNPreeditStartCallback)==0) { ! ic->core.preedit_attr.callbacks.start.client_data = ! ((XIMCallback *)p->value)->client_data; ! ic->core.preedit_attr.callbacks.start.callback = ! ((XIMCallback *)p->value)->callback; ! ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; ! } ! else if(strcmp(p->name, XNPreeditDoneCallback)==0) { ! ic->core.preedit_attr.callbacks.done.client_data = ! ((XIMCallback *)p->value)->client_data; ! ic->core.preedit_attr.callbacks.done.callback = ! ((XIMCallback *)p->value)->callback; ! ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; ! } ! else if(strcmp(p->name, XNPreeditDrawCallback)==0) { ! ic->core.preedit_attr.callbacks.draw.client_data = ! ((XIMCallback *)p->value)->client_data; ! ic->core.preedit_attr.callbacks.draw.callback = ! ((XIMCallback *)p->value)->callback; ! ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; ! } ! else if(strcmp(p->name, XNPreeditCaretCallback)==0) { ! ic->core.preedit_attr.callbacks.caret.client_data = ! ((XIMCallback *)p->value)->client_data; ! ic->core.preedit_attr.callbacks.caret.callback = ! ((XIMCallback *)p->value)->callback; ! ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; ! } } ! return(True); } static Bool _Ximp_StatusSetAttributes(ic, attr, vl, mode, change_mask, return_name) ! Ximp_XIC ic; ! Ximp_StatusPropRec *attr; ! XIMArg *vl; ! int mode; ! int *change_mask; ! char *return_name; ! { XIMArg *p; ! Colormap colormap_ret; int list_ret; XFontStruct **struct_list; char **name_list; int i, len; char *tmp; ! for(p = vl; p->name != NULL; p++) { if(strcmp(p->name, XNArea)==0) { ic->core.status_attr.area.x = ((XRectangle *)p->value)->x; ic->core.status_attr.area.y = ((XRectangle *)p->value)->y; --- 131,585 ---- char * _Ximp_SetICValues(ic, values) ! Ximp_XIC ic; ! XIMArg *values; ! { ! XIM im; ! char *ret; ! XimpChangeMaskRec change_mask; ! XIMP_SET_NULLMASK(change_mask); ! if(!IS_SERVER_CONNECTED(ic->core.im) && IS_RECONNECTABLE(ic->core.im)) ! _Ximp_ConnectServer(ic->core.im); ! if( IS_SERVER_CONNECTED(ic->core.im) && !IS_IC_CONNECTED(ic) ) ! if( _Ximp_ConnectIC( ic, XIMP_START_IC ) ) ! if( IS_RESTARTABLE(ic->core.im) ) ! _Ximp_CallRestartCallbackExtension( ic ); ! if((ret = _Ximp_SetICValueData(ic, values, XIMP_SET_IC, &change_mask))) ! return ret; ! if( (ic->ximp_icpart->value_mask & XIMP_RES_NAME) ! || (ic->ximp_icpart->value_mask & XIMP_RES_CLASS) ) ! _Ximp_SetValue_Resource(ic, &change_mask); ! ! if(!IS_IC_CONNECTED(ic)) { ! if(XIMP_CHK_PROP_FOCUS(change_mask)) { ! if(ic->ximp_icpart->filter_mode & 0x1) { ! _XUnregisterFilter (ic->core.im->core.display, ! ic->ximp_icpart->back_focus_win, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! _XUnregisterFilter (ic->core.im->core.display, ! ic->ximp_icpart->back_focus_win, ! _Ximp_XimFilter_Keyrelease, ! (XPointer)ic); ! } ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyPress, KeyPress, ! _Ximp_XimFilter_Keypress, ! (XPointer)ic); ! _XRegisterFilterByType (ic->core.im->core.display, ! ic->core.focus_window, ! KeyRelease, KeyRelease, ! _Ximp_XimFilter_Keyrelease, ! (XPointer)ic); ! ic->ximp_icpart->filter_mode |= 0x1; } ! return(ret); ! } ! /* IS_IC_CONNECTED == True */ ! if(XIMP_EQU_PRESPOTLMASK(change_mask)) { ! if( IS_BEING_PREEDITED(ic) ) { ! _Ximp_IM_SendMessage(ic, XIMP_MOVE(ic), ! ic->ximp_icpart->preedit_attr.SpotLocation.x, ! ic->ximp_icpart->preedit_attr.SpotLocation.y, ! NULL); } return(ret); + } + if(XIMP_CHK_PROP_FOCUS(change_mask)) { + if(ISXimp4(ic)) { + _Ximp_SetFocusWindowFilter(ic); + XIMP_UNSET_PROPFOCUS(change_mask); + } else { + _Ximp_SetFocusWindowProp(ic); + _Ximp_SetFocusWindowFilter(ic); + } + } + if(!( (ic->core.input_style & XIMPreeditCallbacks) + || (ic->core.input_style & XIMPreeditNone) ) ) { + if(XIMP_CHK_PROP_PREEDIT(change_mask)) + _Ximp_SetPreeditAtr(ic); + if(XIMP_CHK_PROP_PREFONT(change_mask)) + _Ximp_SetPreeditFont(ic); + } else { + XIMP_UNSET_PROPPREEDIT(change_mask); + } + if(!( (ic->core.input_style & XIMStatusCallbacks) + || (ic->core.input_style & XIMStatusNone) ) ) { + if(XIMP_CHK_PROP_STATUS(change_mask)) + _Ximp_SetStatusAtr(ic); + if(XIMP_CHK_PROP_STSFONT(change_mask)) + _Ximp_SetStatusFont(ic); + } else { + XIMP_UNSET_PROPSTATUS(change_mask); + } + if(XIMP_PROTO_MASK(ic, change_mask)) { + XWindowAttributes war; + long mask; + + XGetWindowAttributes( ic->core.im->core.display, + ic->core.client_window, &war ); + XSelectInput( ic->core.im->core.display, ic->core.client_window, + war.your_event_mask | PropertyChangeMask ); + _Ximp_IM_SendMessage(ic, XIMP_SETVALUE(ic), XIMP_PROTO_MASK(ic,change_mask), NULL, NULL); + if( XIMP_CHK_PROP_FOCUS(change_mask) ) + if( !_XimpPNIfEvent( ic, ((Ximp_XIM)ic->core.im)->ximp_impart->focus_win_id ) ) { + XIMP_SET_NULLMASK(change_mask); + } + if( XIMP_CHK_PROP_PREEDIT(change_mask) ) + if( !_XimpPNIfEvent( ic, ((Ximp_XIM)ic->core.im)->ximp_impart->preedit_atr_id ) ) { + XIMP_SET_NULLMASK(change_mask); + } + if( XIMP_CHK_PROP_PREFONT(change_mask) ) + if( !_XimpPNIfEvent( ic, ((Ximp_XIM)ic->core.im)->ximp_impart->preeditfont_id ) ) { + XIMP_SET_NULLMASK(change_mask); + } + if( XIMP_CHK_PROP_STATUS(change_mask) ) + if( !_XimpPNIfEvent( ic, ((Ximp_XIM)ic->core.im)->ximp_impart->status_atr_id ) ) { + XIMP_SET_NULLMASK(change_mask); + } + if( XIMP_CHK_PROP_STSFONT(change_mask) ) + _XimpPNIfEvent( ic, ((Ximp_XIM)ic->core.im)->ximp_impart->statusfont_id ); + XSelectInput( ic->core.im->core.display, ic->core.client_window, + war.your_event_mask ); + } + return(ret); } char * _Ximp_SetICValueData(ic, values, mode, change_mask) ! Ximp_XIC ic; ! XIMArg *values; ! int mode; ! XimpChangeaMask change_mask; ! { ! XIMArg *p; ! char *return_name = NULL; ! XimpCMPredicateArgRec Arg; /* for Ximp4.0 */ ! XEvent event; /* for Ximp4.0 */ ! for(p = values; p->name != NULL; p++) { ! if(strcmp(p->name, XNInputStyle) == 0) { ! if(mode == XIMP_CREATE_IC) { ! ic->core.input_style = (XIMStyle)p->value; ! ic->ximp_icpart->value_mask |= XIMP_INPUT_STYLE; ! } else { ! ; /* Currently Fixed value */ ! } ! } else if(strcmp(p->name, XNClientWindow)==0) { ! if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { ! Window client_window_old; ! unsigned long dummy_mask; ! if(mode == XIMP_SET_IC && (IS_IC_CONNECTED(ic))) { ! if(ISXimp4(ic)) { ! _Ximp_GetFocusWindowSelectMask(ic, (Window)p->value, &dummy_mask); ! _Ximp_IM_SendMessage(ic, XIMP_CLIENT_WINDOW(ic), (Window)p->value, dummy_mask, NULL); ! Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; ! Arg.icid = ic->ximp_icpart->icid; ! Arg.protocol = XIMP_CLIENT_WINDOW_RETURN(ic); ! Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; ! if(!_XimpIfEvent(ic, &event, _Ximp_CMPredicate32, (XPointer)&Arg)) ! return NULL; ! client_window_old = ic->core.client_window; ! ic->core.client_window = (Window)p->value; ! ic->ximp_icpart->value_mask |= XIMP_CLIENT_WIN; ! } else { ! long icid_old, icid_new; ! ! icid_old = ic->ximp_icpart->icid; ! client_window_old = ic->core.client_window; ! ic->ximp_icpart->value_mask |= XIMP_CLIENT_WIN; ! ic->core.client_window = (Window)p->value; ! if(_Ximp_ConnectIC(ic, mode) == False) { ! return_name = p->name; ! ic->ximp_icpart->value_mask &= ~XIMP_CLIENT_WIN; ! ic->core.client_window = client_window_old; ! break; } ! icid_new = ic->ximp_icpart->icid; ! ic->ximp_icpart->icid = icid_old; ! _Ximp_IM_SendMessage(ic, XIMP_DESTROY(ic), NULL, NULL, NULL); ! ic->ximp_icpart->icid = icid_new; ! XDestroyWindow(ic->core.im->core.display, client_window_old); ! XIMP_SET_NULLMASK2(change_mask); ! } ! } else { /* XIMP_CREATE_IC | (XIMP_SET_IC && XIMP_START_IC) */ ! client_window_old = ic->core.client_window; ! ic->core.client_window = (Window)p->value; ! ic->ximp_icpart->value_mask |= XIMP_CLIENT_WIN; ! if(!(XIMP_CHK_FOCUSWINMASK(ic))) { ! ic->core.focus_window = ic->core.client_window; ! XIMP_SET_FOCUSWINMASK(ic); ! } ! } ! if( ic->ximp_icpart->filter_mode & 0x4 ) { ! _XUnregisterFilter( ic->core.im->core.display, ! client_window_old, ! _Ximp_XimFilter_Client, (XPointer)ic); ! _XRegisterFilterByType(ic->core.im->core.display, ! ic->core.client_window, ! ClientMessage, ClientMessage, ! _Ximp_XimFilter_Client, ! (XPointer)ic ); ! } ! } else { ! return_name = p->name; ! break; /* Can't change this value */ ! } ! } else if(strcmp(p->name, XNFocusWindow)==0) { ! if(IS_IC_CONNECTED(ic) && (mode == XIMP_SET_IC)) { ! Window new_focus_window = (Window)p->value; ! unsigned long dummy_mask; ! unsigned long temp_mask; ! XWindowAttributes wattr; ! if(ISXimp4(ic)) { ! XGetWindowAttributes(ic->core.im->core.display, new_focus_window, &wattr); ! dummy_mask = wattr.your_event_mask; ! temp_mask = dummy_mask; ! if(ISFE2(ic) || (ISFE1(ic) && IS_BEING_PREEDITED(ic))) ! dummy_mask &= ~(KeyPressMask | KeyReleaseMask); ! else if(IS_FORCESELECTKEYRELEASE(ic->core.im) && (ISBE2(ic)||(ISBE1(ic)&&IS_BEING_PREEDITED(ic)))) ! dummy_mask |= (KeyReleaseMask); ! _Ximp_IM_SendMessage(ic, XIMP_FOCUS_WINDOW(ic), new_focus_window, temp_mask, NULL); ! Arg.type = ((Ximp_XIM)ic->core.im)->ximp_impart->improtocol_id; ! Arg.icid = ic->ximp_icpart->icid; ! Arg.protocol = XIMP_FOCUS_WINDOW_RETURN(ic); ! Arg.owner = ((Ximp_XIM)ic->core.im)->ximp_impart->fe_window; ! if(!_XimpIfEvent(ic, &event, _Ximp_CMPredicate32, (XPointer)&Arg)) ! return NULL; ! XSelectInput(ic->core.im->core.display, new_focus_window, dummy_mask); ! if(ic->ximp_icpart->back_focus_win) ! XSelectInput(ic->core.im->core.display, ic->core.focus_window, ! ic->ximp_icpart->back_mask); ! ic->ximp_icpart->back_mask = temp_mask; ! } else { /* Ximp 3.5 */ ! if(IS_BEING_PREEDITED(ic)) { ! if(ISXIMP3FE(ic)) { ! XSelectInput(ic->core.im->core.display, ic->core.focus_window, ! ic->ximp_icpart->back_mask); ! XGetWindowAttributes(ic->core.im->core.display, new_focus_window, &wattr); ! dummy_mask = wattr.your_event_mask; ! ic->ximp_icpart->back_mask = dummy_mask; ! if(ISXIMP3FE(ic)) { ! dummy_mask &= ~(KeyPressMask | KeyReleaseMask); ! } ! XSelectInput(ic->core.im->core.display, new_focus_window, dummy_mask); } ! } } ! ic->ximp_icpart->back_focus_win = ic->core.focus_window; ! ic->core.focus_window = (Window)p->value; ! XIMP_SET_FOCUSWINMASK2(ic, change_mask); ! } else { ! ic->ximp_icpart->back_focus_win = ic->core.focus_window; ! ic->core.focus_window = (Window)p->value; ! XIMP_SET_FOCUSWINMASK2(ic, change_mask); ! } ! } else if(strcmp(p->name, XNResourceName)==0) { ! ic->core.im->core.res_name = (char *)p->value; ! ic->ximp_icpart->value_mask |= XIMP_RES_NAME; ! } else if(strcmp(p->name, XNResourceClass)==0) { ! ic->core.im->core.res_class = (char *)p->value; ! ic->ximp_icpart->value_mask |= XIMP_RES_CLASS; ! } else if(strcmp(p->name, XNGeometryCallback)==0) { ! ic->core.geometry_callback.client_data = ! ((XIMCallback *)p->value)->client_data; ! ic->core.geometry_callback.callback = ! ((XIMCallback *)p->value)->callback; ! ic->ximp_icpart->value_mask |= XIMP_GEOMETRY_CB; ! } else if(strcmp(p->name, XNPreeditAttributes)==0) { ! if( _Ximp_PreSetAttributes(ic, ! &(ic->ximp_icpart->preedit_attr), ! p->value, mode, change_mask, ! return_name) == False ) ! break; ! } else if(strcmp(p->name, XNStatusAttributes)==0) { ! if( _Ximp_StatusSetAttributes(ic, ! &(ic->ximp_icpart->status_attr), ! p->value, mode, change_mask, ! return_name) == False ) ! break; ! } else { ! if( _Ximp_SetICExtension(ic, p->name, p->value, mode) == False ) { ! return_name = p->name; ! break; ! } } ! } ! return(return_name); ! } ! static Bool _Ximp_PreSetAttributes(ic, attr, vl, mode, change_mask, return_name) ! Ximp_XIC ic; ! Ximp_PreeditPropRec4 *attr; ! XIMArg *vl; ! int mode; ! XimpChangeaMask change_mask; ! char *return_name; ! { ! XIMArg *p; ! XStandardColormap *colormap_ret; ! int list_ret; ! XFontStruct **struct_list; ! char **name_list; ! int i, len; ! int count; ! char *tmp; ! for(p = vl; p && p->name != NULL; p++) { ! if(strcmp(p->name, XNArea)==0) { ! ic->core.preedit_attr.area.x = ((XRectangle *)p->value)->x; ! ic->core.preedit_attr.area.y = ((XRectangle *)p->value)->y; ! ic->core.preedit_attr.area.width = ((XRectangle *)p->value)->width; ! ic->core.preedit_attr.area.height = ((XRectangle *)p->value)->height; ! attr->Area.x = ic->core.preedit_attr.area.x; ! attr->Area.y = ic->core.preedit_attr.area.y; ! attr->Area.width = ic->core.preedit_attr.area.width; ! attr->Area.height = ic->core.preedit_attr.area.height; ! XIMP_SET_PREAREAMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNAreaNeeded)==0) { ! ic->core.preedit_attr.area_needed.width = ((XRectangle *)p->value)->width; ! ic->core.preedit_attr.area_needed.height = ((XRectangle *)p->value)->height; ! attr->AreaNeeded.width = ic->core.preedit_attr.area_needed.width; ! attr->AreaNeeded.height = ic->core.preedit_attr.area_needed.height; ! XIMP_SET_PREAREANEEDMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNSpotLocation)==0) { ! ic->core.preedit_attr.spot_location.x = ((XPoint *)p->value)->x; ! ic->core.preedit_attr.spot_location.y = ((XPoint *)p->value)->y; ! attr->SpotLocation.x = ic->core.preedit_attr.spot_location.x; ! attr->SpotLocation.y = ic->core.preedit_attr.spot_location.y; ! XIMP_SET_PRESPOTLMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNColormap)==0) { ! ic->core.preedit_attr.colormap = (Colormap)p->value; ! attr->Colormap = ic->core.preedit_attr.colormap; ! XIMP_SET_PRECOLORMAPMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNStdColormap)==0) { ! if( XGetRGBColormaps(ic->core.im->core.display, ! ic->core.focus_window, &colormap_ret, ! &count, (Atom)p->value) != 0) { ! ic->core.preedit_attr.std_colormap = (Atom)p->value; ! attr->StdColormap = ic->core.preedit_attr.std_colormap; ! XIMP_SET_PRESTDCOLORMAPMASK(ic, change_mask); ! } else { ! return_name = p->name; ! return(False); ! } ! ! } else if(strcmp(p->name, XNBackground)==0) { ! ic->core.preedit_attr.background = (unsigned long)p->value; ! attr->Background = ic->core.preedit_attr.background; ! XIMP_SET_PREBGMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNForeground)==0) { ! ic->core.preedit_attr.foreground = (unsigned long)p->value; ! attr->Foreground = ic->core.preedit_attr.foreground; ! XIMP_SET_PREFGMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNBackgroundPixmap)==0) { ! ic->core.preedit_attr.background_pixmap = (Pixmap)p->value; ! attr->Bg_Pixmap = ic->core.preedit_attr.background_pixmap; ! XIMP_SET_PREBGPIXMAPMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNFontSet)==0) { ! ic->core.preedit_attr.fontset = (XFontSet)p->value; ! if(p->value != NULL) { ! if(ic->ximp_icpart->preedit_font) ! Xfree(ic->ximp_icpart->preedit_font); ! list_ret = XFontsOfFontSet(ic->core.preedit_attr.fontset, ! &struct_list, &name_list); ! for(i = 0, len = 0; i < list_ret; i++) { ! len += (strlen(name_list[i]) + sizeof(char)); } ! if((tmp = Xmalloc(len + list_ret + sizeof(char))) == NULL) { ! return_name = p->name; ! return False ; ! } ! tmp[0] = NULL; ! for(i = 0; i < list_ret; i++) { ! strcat(tmp, name_list[i]); ! strcat(tmp, ","); ! } ! tmp[len + i - 1] = NULL; ! ic->ximp_icpart->preedit_font = tmp; ! XIMP_SET_PREFONTMASK(ic, change_mask); ! } else { ! return_name = p->name; ! return(False); ! } ! ! } else if(strcmp(p->name, XNLineSpace)==0) { ! ic->core.preedit_attr.line_space = (long)p->value; ! attr->LineSpacing = ic->core.preedit_attr.line_space; ! XIMP_SET_PRELINESPMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNCursor)==0) { ! ic->core.preedit_attr.cursor = (Cursor)p->value; ! attr->Cursor = ic->core.preedit_attr.cursor; ! XIMP_SET_PRECURSORMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNPreeditStartCallback)==0) { ! ic->core.preedit_attr.callbacks.start.client_data = ! ((XIMCallback *)p->value)->client_data; ! ic->core.preedit_attr.callbacks.start.callback = ! ((XIMCallback *)p->value)->callback; ! ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; ! ! } else if(strcmp(p->name, XNPreeditDoneCallback)==0) { ! ic->core.preedit_attr.callbacks.done.client_data = ! ((XIMCallback *)p->value)->client_data; ! ic->core.preedit_attr.callbacks.done.callback = ! ((XIMCallback *)p->value)->callback; ! ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; ! ! } else if(strcmp(p->name, XNPreeditDrawCallback)==0) { ! ic->core.preedit_attr.callbacks.draw.client_data = ! ((XIMCallback *)p->value)->client_data; ! ic->core.preedit_attr.callbacks.draw.callback = ! ((XIMCallback *)p->value)->callback; ! ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; ! ! } else if(strcmp(p->name, XNPreeditCaretCallback)==0) { ! ic->core.preedit_attr.callbacks.caret.client_data = ! ((XIMCallback *)p->value)->client_data; ! ic->core.preedit_attr.callbacks.caret.callback = ! ((XIMCallback *)p->value)->callback; ! ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; } + } + return(True); + } static Bool _Ximp_StatusSetAttributes(ic, attr, vl, mode, change_mask, return_name) ! Ximp_XIC ic; ! Ximp_StatusPropRec4 *attr; ! XIMArg *vl; ! int mode; ! XimpChangeaMask change_mask; ! char *return_name; ! { XIMArg *p; ! XStandardColormap *colormap_ret; int list_ret; XFontStruct **struct_list; char **name_list; int i, len; + int count; char *tmp; ! for(p = vl; p && p->name != NULL; p++) { if(strcmp(p->name, XNArea)==0) { ic->core.status_attr.area.x = ((XRectangle *)p->value)->x; ic->core.status_attr.area.y = ((XRectangle *)p->value)->y; *************** *** 529,646 **** attr->Area.y = ic->core.status_attr.area.y; attr->Area.width = ic->core.status_attr.area.width; attr->Area.height = ic->core.status_attr.area.height; ! ic->ximp_icpart->proto_mask |= XIMP_STS_AREA_MASK; ! *change_mask |= XIMP_STS_AREA_MASK; ! } ! else if(strcmp(p->name, XNAreaNeeded)==0) { ic->core.status_attr.area_needed.width = ((XRectangle *)p->value)->width; ic->core.status_attr.area_needed.height = ((XRectangle *)p->value)->height; attr->AreaNeeded.width = ic->core.status_attr.area_needed.width; attr->AreaNeeded.height = ic->core.status_attr.area_needed.height; ! ic->ximp_icpart->proto_mask |= XIMP_STS_AREANEED_MASK; ! *change_mask |= XIMP_STS_AREANEED_MASK; ! } ! else if(strcmp(p->name, XNColormap)==0) { ic->core.status_attr.colormap = (Colormap)p->value; attr->Colormap = ic->core.status_attr.colormap; ! ic->ximp_icpart->proto_mask |= XIMP_STS_COLORMAP_MASK; ! *change_mask |= XIMP_STS_COLORMAP_MASK; ! } ! else if(strcmp(p->name, XNStdColormap)==0) { ! if(XGetStandardColormap(ic->core.im->core.display, ! ic->core.focus_window, ! &colormap_ret, (Atom)p->value) !=0) { ! ic->core.status_attr.colormap = colormap_ret; ! attr->Colormap = ic->core.status_attr.colormap; ! ic->ximp_icpart->proto_mask |= XIMP_STS_COLORMAP_MASK; ! *change_mask |= XIMP_STS_COLORMAP_MASK; ! } ! else { return_name = p->name; return(False); - } } ! else if(strcmp(p->name, XNBackground)==0) { ic->core.status_attr.background = (unsigned long)p->value; attr->Background = ic->core.status_attr.background; ! ic->ximp_icpart->proto_mask |= XIMP_STS_BG_MASK; ! *change_mask |= XIMP_STS_BG_MASK; ! } ! else if(strcmp(p->name, XNForeground)==0) { ic->core.status_attr.foreground = (unsigned long)p->value; attr->Foreground = ic->core.status_attr.foreground; ! ic->ximp_icpart->proto_mask |= XIMP_STS_FG_MASK; ! *change_mask |= XIMP_STS_FG_MASK; ! } ! else if(strcmp(p->name, XNBackgroundPixmap)==0) { ic->core.status_attr.background_pixmap = (Pixmap)p->value; attr->Bg_Pixmap = ic->core.status_attr.background_pixmap; ! ic->ximp_icpart->proto_mask |= XIMP_STS_BGPIXMAP_MASK; ! *change_mask |= XIMP_STS_BGPIXMAP_MASK; ! } ! else if(strcmp(p->name, XNFontSet)==0) { ic->core.status_attr.fontset = (XFontSet)p->value; if (p->value != NULL) { if(ic->ximp_icpart->status_font) ! Xfree(ic->ximp_icpart->status_font); ! list_ret = XFontsOfFontSet( ! ic->core.status_attr.fontset, ! &struct_list, &name_list); for(i = 0, len = 0; i < list_ret; i++) { ! len += strlen(name_list[i]); ! } ! if( (tmp = Xmalloc(len + i + 1)) == NULL ) { return_name = p->name; ! return( False ); } tmp[0] = NULL; for(i = 0; i < list_ret; i++) { strcat(tmp, name_list[i]); strcat(tmp, ","); ! } tmp[len + i - 1] = NULL; ic->ximp_icpart->status_font = tmp; ! ic->ximp_icpart->proto_mask |= XIMP_STS_FONT_MASK; ! *change_mask |= XIMP_STS_FONT_MASK; ! } ! else { return_name = p->name; return(False); - } } ! else if(strcmp(p->name, XNLineSpace)==0) { ic->core.status_attr.line_space = (long)p->value; attr->LineSpacing = ic->core.status_attr.line_space; ! ic->ximp_icpart->proto_mask |= XIMP_STS_LINESP_MASK; ! *change_mask |= XIMP_STS_LINESP_MASK; ! } ! else if(strcmp(p->name, XNCursor)==0) { ic->core.status_attr.cursor = (Cursor)p->value; attr->Cursor = ic->core.status_attr.cursor; ! ic->ximp_icpart->proto_mask |= XIMP_STS_CURSOR_MASK; ! *change_mask |= XIMP_STS_CURSOR_MASK; ! } ! else if(strcmp(p->name, XNStatusStartCallback)==0) { ic->core.status_attr.callbacks.start.client_data = ((XIMCallback *)p->value)->client_data; ic->core.status_attr.callbacks.start.callback = ((XIMCallback *)p->value)->callback; ic->ximp_icpart->value_mask |= XIMP_STS_CALLBAK; ! } ! else if(strcmp(p->name, XNStatusDoneCallback)==0) { ic->core.status_attr.callbacks.done.client_data = ((XIMCallback *)p->value)->client_data; ic->core.status_attr.callbacks.done.callback = ((XIMCallback *)p->value)->callback; ic->ximp_icpart->value_mask |= XIMP_STS_CALLBAK; ! } ! else if(strcmp(p->name, XNStatusDrawCallback)==0) { ic->core.status_attr.callbacks.draw.client_data = ((XIMCallback *)p->value)->client_data; ic->core.status_attr.callbacks.draw.callback = ((XIMCallback *)p->value)->callback; ic->ximp_icpart->value_mask |= XIMP_STS_CALLBAK; - } } - return(True); } --- 589,694 ---- attr->Area.y = ic->core.status_attr.area.y; attr->Area.width = ic->core.status_attr.area.width; attr->Area.height = ic->core.status_attr.area.height; ! XIMP_SET_STSAREAMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNAreaNeeded)==0) { ic->core.status_attr.area_needed.width = ((XRectangle *)p->value)->width; ic->core.status_attr.area_needed.height = ((XRectangle *)p->value)->height; attr->AreaNeeded.width = ic->core.status_attr.area_needed.width; attr->AreaNeeded.height = ic->core.status_attr.area_needed.height; ! XIMP_SET_STSAREANEEDMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNColormap)==0) { ic->core.status_attr.colormap = (Colormap)p->value; attr->Colormap = ic->core.status_attr.colormap; ! XIMP_SET_STSCOLORMAPMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNStdColormap)==0) { ! if(XGetRGBColormaps(ic->core.im->core.display, ! ic->core.focus_window, &colormap_ret, ! &count, (Atom)p->value) !=0) { ! ic->core.status_attr.std_colormap = (Atom)p->value; ! attr->StdColormap = ic->core.status_attr.std_colormap; ! XIMP_SET_STSSTDCOLORMAPMASK(ic, change_mask); ! } else { return_name = p->name; return(False); } ! ! } else if(strcmp(p->name, XNBackground)==0) { ic->core.status_attr.background = (unsigned long)p->value; attr->Background = ic->core.status_attr.background; ! XIMP_SET_STSBGMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNForeground)==0) { ic->core.status_attr.foreground = (unsigned long)p->value; attr->Foreground = ic->core.status_attr.foreground; ! XIMP_SET_STSFGMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNBackgroundPixmap)==0) { ic->core.status_attr.background_pixmap = (Pixmap)p->value; attr->Bg_Pixmap = ic->core.status_attr.background_pixmap; ! XIMP_SET_STSBGPIXMAPMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNFontSet)==0) { ic->core.status_attr.fontset = (XFontSet)p->value; if (p->value != NULL) { if(ic->ximp_icpart->status_font) ! Xfree(ic->ximp_icpart->status_font); ! list_ret = XFontsOfFontSet(ic->core.status_attr.fontset, ! &struct_list, &name_list); for(i = 0, len = 0; i < list_ret; i++) { ! len += (strlen(name_list[i]) + sizeof(char)); ! } ! if((tmp = Xmalloc(len + list_ret + sizeof(char))) == NULL){ return_name = p->name; ! return False ; } tmp[0] = NULL; for(i = 0; i < list_ret; i++) { strcat(tmp, name_list[i]); strcat(tmp, ","); ! } tmp[len + i - 1] = NULL; ic->ximp_icpart->status_font = tmp; ! XIMP_SET_STSFONTMASK(ic, change_mask); ! } else { return_name = p->name; return(False); } ! ! } else if(strcmp(p->name, XNLineSpace)==0) { ic->core.status_attr.line_space = (long)p->value; attr->LineSpacing = ic->core.status_attr.line_space; ! XIMP_SET_STSLINESPMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNCursor)==0) { ic->core.status_attr.cursor = (Cursor)p->value; attr->Cursor = ic->core.status_attr.cursor; ! XIMP_SET_STSCURSORMASK(ic, change_mask); ! ! } else if(strcmp(p->name, XNStatusStartCallback)==0) { ic->core.status_attr.callbacks.start.client_data = ((XIMCallback *)p->value)->client_data; ic->core.status_attr.callbacks.start.callback = ((XIMCallback *)p->value)->callback; ic->ximp_icpart->value_mask |= XIMP_STS_CALLBAK; ! ! } else if(strcmp(p->name, XNStatusDoneCallback)==0) { ic->core.status_attr.callbacks.done.client_data = ((XIMCallback *)p->value)->client_data; ic->core.status_attr.callbacks.done.callback = ((XIMCallback *)p->value)->callback; ic->ximp_icpart->value_mask |= XIMP_STS_CALLBAK; ! ! } else if(strcmp(p->name, XNStatusDrawCallback)==0) { ic->core.status_attr.callbacks.draw.client_data = ((XIMCallback *)p->value)->client_data; ic->core.status_attr.callbacks.draw.callback = ((XIMCallback *)p->value)->callback; ic->ximp_icpart->value_mask |= XIMP_STS_CALLBAK; } } + + return(True); + } *** /tmp/d03871 Tue Mar 9 09:21:59 1993 --- mit/lib/X/Ximp/XimpMPer.c Tue Mar 9 09:21:57 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpMPer.c,v 1.2 92/04/14 13:29:43 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpMPer.c,v 1.3 92/10/19 19:25:49 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *** /tmp/d03893 Tue Mar 9 09:22:11 1993 --- mit/lib/X/Ximp/XimpMPrTxt.c Tue Mar 9 09:22:08 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpMPrTxt.c,v 1.3 92/04/14 13:29:46 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpMPrTxt.c,v 1.4 92/10/19 19:25:52 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 70,79 **** #include #include ! extern int _Ximp_strcpy(), _Ximp_cttombs(); int XmbTextPropertyToTextList(dpy, text_prop, list_ret, count_ret) Display *dpy; XTextProperty *text_prop; char ***list_ret; --- 70,84 ---- #include #include ! extern int _Xlc_strcpy(), _Ximp_cttombs(); int + #ifndef DYNAMICLIB XmbTextPropertyToTextList(dpy, text_prop, list_ret, count_ret) + #else + _XimpmbTextPropertyToTextList(lcd, dpy, text_prop, list_ret, count_ret) + XLCd lcd; + #endif Display *dpy; XTextProperty *text_prop; char ***list_ret; *************** *** 82,90 **** unsigned char **list; unsigned char *buf, *buf_ptr, *str_ptr; int i, count, unconv_num, tmp_len, buf_len; ! #define CNV_STR_FUNC _Ximp_strcpy #define CNV_CTEXT_FUNC _Ximp_cttombs ! #define CNV_TEXT_FUNC _Ximp_strcpy /* XXX */ buf_len = text_prop->nitems + 1; --- 87,95 ---- unsigned char **list; unsigned char *buf, *buf_ptr, *str_ptr; int i, count, unconv_num, tmp_len, buf_len; ! #define CNV_STR_FUNC _Xlc_strcpy #define CNV_CTEXT_FUNC _Ximp_cttombs ! #define CNV_TEXT_FUNC _Xlc_strcpy /* XXX */ buf_len = text_prop->nitems + 1; *** /tmp/d03916 Tue Mar 9 09:22:22 1993 --- mit/lib/X/Ximp/XimpMTxtPr.c Tue Mar 9 09:22:19 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpMTxtPr.c,v 1.3 92/04/14 13:29:49 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpMTxtPr.c,v 1.4 92/10/19 19:25:56 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 70,80 **** #include #include ! extern int _Ximp_mbstostring(), _Ximp_mbstoct(), _Ximp_strcpy(); int XmbTextListToTextProperty(dpy, list, count, style, text_prop) Display *dpy; char **list; int count; --- 70,85 ---- #include #include ! extern int _Ximp_mbstostring(), _Ximp_mbstoct(), _Xlc_strcpy(); int + #ifndef DYNAMICLIB XmbTextListToTextProperty(dpy, list, count, style, text_prop) + #else + _XimpmbTextListToTextProperty(lcd, dpy, list, count, style, text_prop) + XLCd lcd; + #endif Display *dpy; char **list; int count; *************** *** 86,92 **** #define CNV_STR_FUNC _Ximp_mbstostring #define CNV_CTEXT_FUNC _Ximp_mbstoct ! #define CNV_TEXT_FUNC _Ximp_strcpy #define STRLEN_FUNC strlen /* XXX */ --- 91,97 ---- #define CNV_STR_FUNC _Ximp_mbstostring #define CNV_CTEXT_FUNC _Ximp_mbstoct ! #define CNV_TEXT_FUNC _Xlc_strcpy #define STRLEN_FUNC strlen /* XXX */ *** /tmp/d03938 Tue Mar 9 09:22:33 1993 --- mit/lib/X/Ximp/XimpPrTxt.c Tue Mar 9 09:22:30 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpPrTxt.c,v 1.3 92/04/14 13:29:53 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpPrTxt.c,v 1.4 92/10/19 19:26:02 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 70,76 **** */ { ! Ximp_XLCd lcd; Atom encoding; unsigned char *last_ptr; int nitems, tmp_num; --- 70,76 ---- */ { ! XLCd lcd; Atom encoding; unsigned char *last_ptr; int nitems, tmp_num; *************** *** 86,92 **** Xfree(buf); return XConverterNotFound; } ! if ((lcd = (Ximp_XLCd) _XlcCurrentLC()) == NULL) { Xfree(buf); return XLocaleNotSupported; } --- 86,92 ---- Xfree(buf); return XConverterNotFound; } ! if ((lcd = _XlcCurrentLC()) == NULL) { Xfree(buf); return XLocaleNotSupported; } *** /tmp/d03960 Tue Mar 9 09:22:44 1993 --- mit/lib/X/Ximp/XimpRm.c Tue Mar 9 09:22:42 1993 *************** *** 1,7 **** ! /* $XConsortium: XimpRm.c,v 1.5 92/07/29 10:16:22 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED Copyright 1991, 1992 by Sony Corporation Permission to use, copy, modify, distribute, and sell this software --- 1,8 ---- ! /* $XConsortium: XimpRm.c,v 1.6 92/10/19 19:26:16 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by FUJITSU LIMITED + Copyright 1991, 1992 by Sun Microsystems, Inc. Copyright 1991, 1992 by Sony Corporation Permission to use, copy, modify, distribute, and sell this software *************** *** 8,32 **** and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear ! in supporting documentation, and that the name of FUJITSU LIMITED ! and Sony Corporaion not be used in advertising or publicity ! pertaining to distribution of the software without specific, written prior permission. ! FUJITSU LIMITED and Sony Corporation make no representations about ! the suitability of this software for any purpose. It is provided ! "as is" without express or implied warranty. ! FUJITSU LIMITED AND SONY CORPORATION DISCLAIM ALL WARRANTIES WITH ! REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND ! SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL ! DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA ! OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ! TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE ! OR PERFORMANCE OF THIS SOFTWARE. Author: Takashi Fujiwara FUJITSU LIMITED ! Makoto Wakamatsu Sony Corporation ******************************************************************/ --- 9,35 ---- and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear ! in supporting documentation, and that the name of FUJITSU LIMITED, ! Sun Microsystems, Inc. and Sony Corporation not be used in advertising ! or publicity pertaining to distribution of the software without specific, written prior permission. ! FUJITSU LIMITED, Sun Microsystems, Inc. and Sony Corporation make no ! representations about the suitability of this software for any purpose. ! It is provided "as is" without express or implied warranty. ! FUJITSU LIMITED, SUN MICROSYSTEMS, INC. AND SONY CORPORATION DISCLAIM ! ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED ! WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU ! LIMITED, SUN MICROSYSTEMS, INC. AND SONY CORPORATION BE LIABLE FOR ANY ! SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ! RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF ! CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN ! CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Author: Takashi Fujiwara FUJITSU LIMITED ! Hiromu Inukai Sun Microsystems, Inc. ! Hideki Hiura Sun Microsystems, Inc. ! Makoto Wakamatsu Sony Corporation ******************************************************************/ *************** *** 37,67 **** #include "Ximplc.h" #include "Xresource.h" ! extern void _Ximp_OpenIMResourceExtension(); - void - _Ximp_Get_resource_name(im, res_name, res_class) - Ximp_XIM im; - char *res_name; - char *res_class; - { - if(im->core.res_name == NULL) - strcpy(res_name, "*"); - else { - strcpy(res_name, im->core.res_name); - strcat(res_name, "."); - } - if(im->core.res_class == NULL) - strcpy(res_class, "*"); - else { - strcpy(res_class, im->core.res_class); - strcat(res_class, "."); - } - strcat(res_name, "ximp."); - strcat(res_class, "Ximp."); - } - - #ifndef isalnum #define isalnum(c) \ (('0' <= (c) && (c) <= '9') || \ --- 40,47 ---- #include "Ximplc.h" #include "Xresource.h" ! extern void _Ximp_OpenIMResourceExtension(); #ifndef isalnum #define isalnum(c) \ (('0' <= (c) && (c) <= '9') || \ *************** *** 69,79 **** ('a' <= (c) && (c) <= 'z')) #endif ! static void _Ximp_parse( im, event ) Ximp_XIM im; char *event; { ! static Ximp_Key key; char *modifier, *detail; char *ss; int ii; --- 49,108 ---- ('a' <= (c) && (c) <= 'z')) #endif ! static void ! _Ximp_Get_resource_name(im, res_name, res_class) Ximp_XIM im; + char *res_name; + char *res_class; + { + if(im->core.res_name == NULL) { + strcpy(res_name, "*"); + } else { + strcpy(res_name, im->core.res_name); + strcat(res_name, "."); + } + if(im->core.res_class == NULL) { + strcpy(res_class, "*"); + } else { + strcpy(res_class, im->core.res_class); + strcat(res_class, "."); + } + strcat(res_name, "ximp."); + strcat(res_class, "Ximp."); + } + + static void + _Ximp_Local_Processing(im) + Ximp_XIM im; + { + char res_name[256]; + char res_class[256]; + char *str_type; + XrmValue value; + + _Ximp_Get_resource_name(im, res_name, res_class); + strcat(res_name, "localProcessing"); + strcat(res_class, "LocalProcessing"); + if(XrmGetResource(im->core.rdb, res_name, res_class, + &str_type, &value) == True) { + if(strcmp(value.addr, "True") == 0 || + strcmp(value.addr, "true") == 0 || + strcmp(value.addr, "Yes") == 0 || + strcmp(value.addr, "yes") == 0 || + strcmp(value.addr, "ON") == 0 || + strcmp(value.addr, "on") == 0) { + IS_LOCAL_PROCESSING(im) = True; + } + } + return; + } + + static void + _Ximp_parse( im, event ) + Ximp_XIM im; char *event; { ! Ximp_Key key; char *modifier, *detail; char *ss; int ii; *************** *** 114,121 **** return; key.modifier_mask = AllMask; modifier += 4; ! } ! else { if( *modifier == '!' ) { if( key.modifier_mask != 0 || exclamation ) return; --- 143,149 ---- return; key.modifier_mask = AllMask; modifier += 4; ! } else { if( *modifier == '!' ) { if( key.modifier_mask != 0 || exclamation ) return; *************** *** 155,162 **** Xfree( keylist ); return; } ! } ! else { Ximp_Key *keys_list; if( (keys_list = (Ximp_Key *)Xrealloc(keylist->keys_list, sizeof(Ximp_Key) * (keylist->count_keys + 1))) == NULL ) return; --- 183,189 ---- Xfree( keylist ); return; } ! } else { Ximp_Key *keys_list; if( (keys_list = (Ximp_Key *)Xrealloc(keylist->keys_list, sizeof(Ximp_Key) * (keylist->count_keys + 1))) == NULL ) return; *************** *** 166,399 **** keylist->count_keys++; im->ximp_impart->process_start_keys = keylist; } } ! Bool ! _Ximp_OpenIM_Resource(im) ! Ximp_XIM im; ! { ! char res_name[256]; ! char res_class[256]; ! char *str_type; ! XrmValue value; ! Bool ret = False; ! KeySym keysym = NoSymbol; ! Ximp_KeyList *keylist; ! if(im->core.rdb == NULL) ! return(ret); ! /* Inputserver */ ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "inputserver"); ! strcat(res_class, "Inputserver"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! if(strcmp(value.addr, "off") == 0) { ! /* Keysym */ ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "startkeysym"); ! strcat(res_class, "Startkeysym"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! keysym = XStringToKeysym(value.addr); ! } ! ret = False; ! if(keysym != NoSymbol) { ! if((keylist = (Ximp_KeyList *)Xmalloc(sizeof(Ximp_KeyList))) != NULL ) { ! if((keylist->keys_list = (Ximp_Key *)Xmalloc(sizeof(Ximp_Key)))!= NULL) { ! keylist->count_keys = 1; ! keylist->keys_list[0].modifier = 0; ! keylist->keys_list[0].modifier_mask = 0; ! keylist->keys_list[0].keysym = keysym; ! im->ximp_impart->process_start_keys = keylist; ! ret = True; ! } ! else ! Xfree(keylist); ! } ! } ! /* ProcessStartKeys */ ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "processStartKeys"); ! strcat(res_class, "ProcessStartKeys"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! char *string, *ss, c; ! char *line; ! if( (line = Xmalloc(value.size)) != NULL ) { ! string = value.addr; ! do { ! ss = line; ! while( (c = *string) != NULL ) { ! string++; ! if( c == '\n' ) ! break; ! *ss++ = c; ! } ! *ss = NULL; ! _Ximp_parse( im, line ); ! } while( *string != NULL ); ! Xfree( line ); ! if( im->ximp_impart->process_start_keys ) ! ret = True; ! } ! } ! } } ! /* Call Back */ _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "callbackEncoding"); ! strcat(res_class, "CallbackEncoding"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! if(strcmp(value.addr, "wchar") == 0) { ! im->ximp_impart->use_wchar = True; ! } ! } ! /* Extension : XOpenIM(, rdb, res_name, res_class) */ ! _Ximp_OpenIMResourceExtension(im); ! return(ret); } void _Ximp_SetValue_Resource(ic, mask) ! Ximp_XIC ic; ! long *mask; ! { ! Ximp_XIM im; ! char res_name[256]; ! char res_class[256]; ! char *str_type; ! XrmValue value; ! Colormap default_colormap; ! XColor screen_def, exact_def; ! int num; ! im = (Ximp_XIM)XIMOfIC((XIC)ic); ! if(im->core.rdb == NULL) ! return; ! if(!( (ic->core.input_style & XIMPreeditCallbacks) ! || (ic->core.input_style & XIMPreeditNone) ) ) { ! if(!(ic->ximp_icpart->proto_mask & XIMP_PRE_BG_MASK)) { ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "preedit.background"); ! strcat(res_class, "Preedit.Background"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! default_colormap = DefaultColormap( ! im->core.display, ! DefaultScreen(im->core.display) ); ! if( XAllocNamedColor(im->core.display, default_colormap, ! value.addr, ! &screen_def, &exact_def) ) { ! ic->core.preedit_attr.background = screen_def.pixel; ! ic->ximp_icpart->preedit_attr.Background = ! ic->core.preedit_attr.background; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_BG_MASK; ! *mask |= XIMP_PRE_BG_MASK; ! } ! } ! } ! if(!(ic->ximp_icpart->proto_mask & XIMP_PRE_FG_MASK)) { ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "preedit.foreground"); ! strcat(res_class, "Preedit.Foreground"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! default_colormap = DefaultColormap( ! im->core.display, ! DefaultScreen(im->core.display) ); ! if( XAllocNamedColor(im->core.display, default_colormap, ! value.addr, ! &screen_def, &exact_def) ) { ! ic->core.preedit_attr.foreground = screen_def.pixel; ! ic->ximp_icpart->preedit_attr.Foreground = ! ic->core.preedit_attr.foreground; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_FG_MASK; ! *mask |= XIMP_PRE_FG_MASK; ! } ! } ! } ! if(!(ic->ximp_icpart->proto_mask & XIMP_PRE_LINESP_MASK)) { ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "preedit.linespacing"); ! strcat(res_class, "Preedit.Linespacing"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! num = atoi(value.addr); ! ic->core.preedit_attr.line_space = num; ! ic->ximp_icpart->preedit_attr.LineSpacing = ! ic->core.preedit_attr.line_space; ! ic->ximp_icpart->proto_mask |= XIMP_PRE_LINESP_MASK; ! *mask |= XIMP_PRE_LINESP_MASK; ! } ! } } ! if(!( (ic->core.input_style & XIMStatusCallbacks) ! || (ic->core.input_style & XIMStatusNone) ) ) { ! if(!(ic->ximp_icpart->proto_mask & XIMP_STS_BG_MASK)) { ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "status.background"); ! strcat(res_class, "Status.Background"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! default_colormap = DefaultColormap( ! im->core.display, ! DefaultScreen(im->core.display) ); ! if( XAllocNamedColor(im->core.display, default_colormap, ! value.addr, ! &screen_def, &exact_def) ) { ! ic->core.status_attr.background = screen_def.pixel; ! ic->ximp_icpart->status_attr.Background = ! ic->core.status_attr.background; ! ic->ximp_icpart->proto_mask |= XIMP_STS_BG_MASK; ! *mask |= XIMP_STS_BG_MASK; ! } ! } ! } ! if(!(ic->ximp_icpart->proto_mask & XIMP_STS_FG_MASK)) { ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "status.foreground"); ! strcat(res_class, "Status.Foreground"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! default_colormap = DefaultColormap( ! im->core.display, ! DefaultScreen(im->core.display) ); ! if( XAllocNamedColor(im->core.display, default_colormap, ! value.addr, ! &screen_def, &exact_def) ) { ! ic->core.status_attr.foreground = screen_def.pixel; ! ic->ximp_icpart->status_attr.Foreground = ! ic->core.status_attr.foreground; ! ic->ximp_icpart->proto_mask |= XIMP_STS_FG_MASK; ! *mask |= XIMP_STS_FG_MASK; ! } ! } ! } ! if(!(ic->ximp_icpart->proto_mask & XIMP_STS_LINESP_MASK)) { ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "status.linespacing"); ! strcat(res_class, "Status.Linespacing"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! num = atoi(value.addr); ! ic->core.status_attr.line_space = num; ! ic->ximp_icpart->status_attr.LineSpacing = ! ic->core.status_attr.line_space; ! ic->ximp_icpart->proto_mask |= XIMP_STS_LINESP_MASK; ! *mask |= XIMP_STS_LINESP_MASK; ! } ! } } ! if( (ic->ximp_icpart->value_mask & XIMP_RES_NAME) ! || (ic->ximp_icpart->value_mask & XIMP_RES_CLASS) ) ! ic->ximp_icpart->value_mask &= ~(XIMP_RES_NAME | XIMP_RES_CLASS); ! return; } --- 193,620 ---- keylist->count_keys++; im->ximp_impart->process_start_keys = keylist; } + return; } + static void + _Ximp_InputServerMode(im) + Ximp_XIM im; + { + char res_name[256]; + char res_class[256]; + char *str_type; + XrmValue value; + KeySym keysym = NoSymbol; + Ximp_KeyList *keylist; + XIMStyles *imstyles; + XIMStyle imstyle1, imstyle2; ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "inputserver"); ! strcat(res_class, "Inputserver"); ! if((XrmGetResource(im->core.rdb, res_name, res_class,&str_type, &value) == True) ! && (strcmp(value.addr, "off") == 0) ) { ! MAKE_CONNECTABLE(im) ; ! } ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "delaybinding"); ! strcat(res_class, "Delaybinding"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value) == True) { ! if(strcmp(value.addr, "ON") == 0 || ! strcmp(value.addr, "on") == 0) { ! MAKE_DELAYBINDABLE(im); ! } ! } ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "reconnect"); ! strcat(res_class, "Reconnect"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value) == True) { ! if(strcmp(value.addr, "ON") == 0 || ! strcmp(value.addr, "on") == 0) { ! MAKE_RECONNECTABLE(im) ; ! } ! } ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "restart"); ! strcat(res_class, "Restart"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value) == True) { ! if(strcmp(value.addr, "ON") == 0 || ! strcmp(value.addr, "on") == 0) { ! MAKE_RESTARTABLE(im) ; ! } ! } ! if(IS_UNCONNECTABLE(im)) ! return; ! ! /* Keysym */ ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "startkeysym"); ! strcat(res_class, "Startkeysym"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value) == True) { ! keysym = XStringToKeysym(value.addr); ! } ! if(keysym != NoSymbol) { ! if((keylist = (Ximp_KeyList *)Xmalloc(sizeof(Ximp_KeyList))) != NULL ) { ! if((keylist->keys_list = (Ximp_Key *)Xmalloc(sizeof(Ximp_Key)))!= NULL) { ! keylist->count_keys = 1; ! keylist->keys_list[0].modifier = 0; ! keylist->keys_list[0].modifier_mask = 0; ! keylist->keys_list[0].keysym = keysym; ! im->ximp_impart->process_start_keys = keylist; ! } else ! Xfree(keylist); ! } ! } ! ! /* ProcessStartKeys */ ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "processStartKeys"); ! strcat(res_class, "ProcessStartKeys"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value) == True) { ! char *string, *ss, c; ! char *line; ! ! if( (line = Xmalloc(value.size)) != NULL ) { ! string = value.addr; ! do { ! ss = line; ! while( (c = *string) != NULL ) { ! string++; ! if( c == '\n' ) ! break; ! *ss++ = c; } ! *ss = NULL; ! _Ximp_parse( im, line ); ! } while( *string != NULL ); ! Xfree( line ); ! } ! } ! ! if(im->ximp_impart->process_start_keys == (Ximp_KeyList *)NULL) ! MAKE_UNCONNECTABLE(im) ; ! ! if(IS_DELAYBINDABLE(im)) { ! imstyle1 = imstyle2 = 0; _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "preeditDefaultStyle"); ! strcat(res_class, "PreeditDefaultStyle"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value) == True) { ! if(strcmp(value.addr, "XIMPreeditArea") == 0) ! imstyle1 = XIMPreeditArea; ! else if(strcmp(value.addr, "XIMPreeditCallbacks") == 0) ! imstyle1 = XIMPreeditCallbacks; ! else if(strcmp(value.addr, "XIMPreeditPosition") == 0) ! imstyle1 = XIMPreeditPosition; ! else if(strcmp(value.addr, "XIMPreeditNothing") == 0) ! imstyle1 = XIMPreeditNothing; ! else if(strcmp(value.addr, "XIMPreeditNone") == 0) ! imstyle1 = XIMPreeditNone; } + if(imstyle1 == 0) + imstyle1 = XIMPreeditNothing; + _Ximp_Get_resource_name(im, res_name, res_class); + strcat(res_name, "statusDefaultStyle"); + strcat(res_class, "StatusDefaultStyle"); + if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value) == True) { + if(strcmp(value.addr, "XIMStatusArea") == 0) + imstyle2 = XIMStatusArea; + else if(strcmp(value.addr, "XIMStatusCallbacks") == 0) + imstyle2 = XIMStatusCallbacks; + else if(strcmp(value.addr, "XIMStatusNothing") == 0) + imstyle2 = XIMStatusNothing; + else if(strcmp(value.addr, "XIMStatusNone") == 0) + imstyle2 = XIMStatusNone; + } + if(imstyle2 == 0) + imstyle2 = XIMStatusNothing; + if((imstyles = (XIMStyles *)Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle))) == NULL) + return; + imstyles->count_styles = 1; + imstyles->supported_styles = (XIMStyle *)((char *)imstyles + sizeof(XIMStyles)); + imstyles->supported_styles[0] = imstyle1 | imstyle2; + im->ximp_impart->delaybind_styles = imstyles; + } + return; + } + + static void + _Ximp_CallBackWchar(im) + Ximp_XIM im; + { + char res_name[256]; + char res_class[256]; + char *str_type; + XrmValue value; + + _Ximp_Get_resource_name(im, res_name, res_class); + strcat(res_name, "callbackEncoding"); + strcat(res_class, "CallbackEncoding"); + if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value) == True) { + if(strcmp(value.addr, "wchar") == 0) { + im->ximp_impart->use_wchar = True; + } + } + return; + } + + static void + _Ximp_ForceSelectKeyRelease(im) + Ximp_XIM im; + { + char res_name[256]; + char res_class[256]; + char *str_type; + XrmValue value; + + _Ximp_Get_resource_name(im, res_name, res_class); + strcat(res_name, "forceSelectKeyRelease"); + strcat(res_class, "ForceSelectKeyRelease"); + if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value) == True) { + if(strcmp(value.addr, "yes") == 0) { /* Ximp 4.0 */ + im->ximp_impart->is_forceselectkeyrelease = True; + } + } + return; + } + + static int + _Ximp_Environ() + { + char *env_p; + #ifdef sun + int ret = XIMP_FE_TYPE3; + #else + int ret = XIMP_FE_TYPE1; + #endif + if((env_p = (char *)getenv("XIMP_TYPE")) != (char *)NULL) { + if(strcmp(env_p, "XIMP_FE_TYPE1") == 0) + ret = XIMP_FE_TYPE1; + else if(strcmp(env_p, "XIMP_FE_TYPE2") == 0) + ret = XIMP_FE_TYPE2; + else if(strcmp(env_p, "XIMP_FE_TYPE3") == 0) + ret = XIMP_FE_TYPE3; + else if(strcmp(env_p, "XIMP_BE_TYPE1") == 0) + ret = XIMP_BE_TYPE1; + else if(strcmp(env_p, "XIMP_BE_TYPE2") == 0) + ret = XIMP_BE_TYPE2; + else if(strcmp(env_p, "XIMP_SYNC_BE_TYPE1") == 0) + ret = XIMP_SYNC_BE_TYPE1; + else if(strcmp(env_p, "XIMP_SYNC_BE_TYPE2") == 0) + ret = XIMP_SYNC_BE_TYPE2; + } + return(ret); + } + + static int + _Ximp_InputTypeResource(im) + Ximp_XIM im; + { + char res_name[256]; + char res_class[256]; + char *str_type; + XrmValue value; + #ifdef sun + int ret = XIMP_FE_TYPE3; + #else + int ret = XIMP_FE_TYPE1; + #endif + + _Ximp_Get_resource_name(im, res_name, res_class); + strcat(res_name, "immode"); + strcat(res_class, "Immode"); + if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value) == True) { + if(strcmp(value.addr, "XIMP_FE_TYPE1") == 0) + ret = XIMP_FE_TYPE1; + else if(strcmp(value.addr, "XIMP_FE_TYPE2") == 0) + ret = XIMP_FE_TYPE2; + else if(strcmp(value.addr, "XIMP_FE_TYPE3") == 0) + ret = XIMP_FE_TYPE3; + else if(strcmp(value.addr, "XIMP_BE_TYPE1") == 0) + ret = XIMP_BE_TYPE1; + else if(strcmp(value.addr, "XIMP_BE_TYPE2") == 0) + ret = XIMP_BE_TYPE2; + else if(strcmp(value.addr, "XIMP_SYNC_BE_TYPE1") == 0) + ret = XIMP_SYNC_BE_TYPE1; + else if(strcmp(value.addr, "XIMP_SYNC_BE_TYPE2") == 0) + ret = XIMP_SYNC_BE_TYPE2; + return(ret); + } + return(-1); + } + void + _Ximp_OpenIM_Resource(im) + Ximp_XIM im; + { + int mode; + + im->ximp_impart->def_svr_mode = _Ximp_Environ(); /* server input type */ + + if(im->core.rdb == NULL) + return; + + /* Local Processing */ + _Ximp_Local_Processing(im); + + /* Inputserver */ + _Ximp_InputServerMode(im); + + /* Input Type */ + if((mode = _Ximp_InputTypeResource(im)) != -1) + im->ximp_impart->def_svr_mode = mode; + + /* Call Back */ + _Ximp_CallBackWchar(im); + + /* Force Select KeyRelease support */ + _Ximp_ForceSelectKeyRelease(im); + + /* Extension Resource */ + _Ximp_OpenIMResourceExtension(im); + return; + } + + void _Ximp_SetValue_Resource(ic, mask) ! Ximp_XIC ic; ! XimpChangeaMask mask; ! { ! Ximp_XIM im; ! char res_name[256]; ! char res_class[256]; ! char *str_type ; ! XrmValue value; ! Colormap default_colormap; ! XColor screen_def, exact_def; ! int num, mode; ! ! im = (Ximp_XIM)XIMOfIC((XIC)ic); ! if(im->core.rdb == NULL) ! return; ! if(!(XIMP_CHK_SERVERTYPEMASK(ic))) { ! if((mode = _Ximp_InputTypeResource(im)) != -1) { ! ic->ximp_icpart->svr_mode = mode; ! XIMP_SET_SERVERTYPEMASK(ic, mask); ! } ! } ! if(!( (ic->core.input_style & XIMPreeditCallbacks) ! || (ic->core.input_style & XIMPreeditNone) ) ) { ! if(!(XIMP_CHK_PREBGMASK(ic))) { ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "preedit.background"); ! strcat(res_class, "Preedit.Background"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! default_colormap = DefaultColormap( ! im->core.display, ! DefaultScreen(im->core.display) ); ! if( XAllocNamedColor(im->core.display, default_colormap, ! value.addr, ! &screen_def, &exact_def) ) { ! ic->core.preedit_attr.background = screen_def.pixel; ! ic->ximp_icpart->preedit_attr.Background = ! ic->core.preedit_attr.background; ! XIMP_SET_PREBGMASK(ic, mask); } ! } ! } ! if(!(XIMP_CHK_PREFGMASK(ic))) { ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "preedit.foreground"); ! strcat(res_class, "Preedit.Foreground"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! default_colormap = DefaultColormap( ! im->core.display, ! DefaultScreen(im->core.display) ); ! if( XAllocNamedColor(im->core.display, default_colormap, ! value.addr, ! &screen_def, &exact_def) ) { ! ic->core.preedit_attr.foreground = screen_def.pixel; ! ic->ximp_icpart->preedit_attr.Foreground = ! ic->core.preedit_attr.foreground; ! XIMP_SET_PREBGMASK(ic, mask); ! } ! } ! } ! if(!(XIMP_CHK_PRELINESPMASK(ic))) { ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "preedit.linespacing"); ! strcat(res_class, "Preedit.Linespacing"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! num = atoi(value.addr); ! ic->core.preedit_attr.line_space = num; ! ic->ximp_icpart->preedit_attr.LineSpacing = ! ic->core.preedit_attr.line_space; ! XIMP_SET_PRELINESPMASK(ic, mask); ! } ! } ! } ! if(!( (ic->core.input_style & XIMStatusCallbacks) ! || (ic->core.input_style & XIMStatusNone) ) ) { ! if(!(XIMP_CHK_STSBGMASK(ic))) { ! _Ximp_Get_resource_name(im, res_name, res_class); ! strcat(res_name, "status.background"); ! strcat(res_class, "Status.Background"); ! if(XrmGetResource(im->core.rdb, res_name, res_class, ! &str_type, &value) == True) { ! default_colormap = DefaultColormap(im->core.display, ! DefaultScreen(im->core.display) ); ! if( XAllocNamedColor(im->core.display, default_colormap, ! value.addr, ! &screen_def, &exact_def) ) { ! ic->core.status_attr.background = screen_def.pixel; ! ic->ximp_icpart->status_attr.Background = ! ic->core.status_attr.background; ! XIMP_SET_STSBGMASK(ic, mask); } ! } } + if(!(XIMP_CHK_STSFGMASK(ic))) { + _Ximp_Get_resource_name(im, res_name, res_class); + strcat(res_name, "status.foreground"); + strcat(res_class, "Status.Foreground"); + if(XrmGetResource(im->core.rdb, res_name, res_class, + &str_type, &value) == True) { + default_colormap = DefaultColormap(im->core.display, + DefaultScreen(im->core.display) ); + if( XAllocNamedColor(im->core.display, default_colormap, + value.addr, + &screen_def, &exact_def) ) { + ic->core.status_attr.foreground = screen_def.pixel; + ic->ximp_icpart->status_attr.Foreground = + ic->core.status_attr.foreground; + XIMP_SET_STSFGMASK(ic, mask); + } + } + } + if(!(XIMP_CHK_STSLINESPMASK(ic))) { + _Ximp_Get_resource_name(im, res_name, res_class); + strcat(res_name, "status.linespacing"); + strcat(res_class, "Status.Linespacing"); + if(XrmGetResource(im->core.rdb, res_name, res_class, + &str_type, &value) == True) { + num = atoi(value.addr); + ic->core.status_attr.line_space = num; + ic->ximp_icpart->status_attr.LineSpacing = + ic->core.status_attr.line_space; + XIMP_SET_STSLINESPMASK(ic, mask); + } + } + } + + if( (ic->ximp_icpart->value_mask & XIMP_RES_NAME) + || (ic->ximp_icpart->value_mask & XIMP_RES_CLASS) ) + ic->ximp_icpart->value_mask &= ~(XIMP_RES_NAME | XIMP_RES_CLASS); + return; + } *** /tmp/d03982 Tue Mar 9 09:22:56 1993 --- mit/lib/X/Ximp/XimpSJIS.c Tue Mar 9 09:22:54 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpSJIS.c,v 1.4 92/04/14 13:29:59 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 Sony Corporation --- 1,4 ---- ! /* $XConsortium: XimpSJIS.c,v 1.5 92/10/19 19:26:21 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 Sony Corporation *************** *** 23,28 **** --- 23,29 ---- PERFORMANCE OF THIS SOFTWARE. Author: Masaki Takeuchi Sony Corporation + Makoto Wakamatsu Sony Corporation ******************************************************************/ *************** *** 34,49 **** #ifdef USE_SJIS - static Bool sjis_initialize(); - static void null_proc(); static char sjis_mbchar(); static int sjis_mbstocs(), sjis_wcstocs(), sjis_cstombs(), sjis_cstowcs(); ! XLCdXimpMethods sjis_lc_methods = { ! sjis_initialize, ! null_proc, ! null_proc, sjis_mbchar, sjis_mbstocs, sjis_wcstocs, --- 35,56 ---- #ifdef USE_SJIS static char sjis_mbchar(); static int sjis_mbstocs(), sjis_wcstocs(), sjis_cstombs(), sjis_cstowcs(); ! static XLCdMethodsRec lcd_methods = { ! _XlcDefaultMapModifiers, ! _XDefaultCreateFontSet, ! _Ximp_OpenIM, ! }; ! ! LCMethodsRec sjis_lc_methods = { ! _XlcDestroyLC, ! _XlcCreateState, ! _XlcDestroyState, ! _XlcCnvStart, ! _XlcCnvEnd, sjis_mbchar, sjis_mbstocs, sjis_wcstocs, *************** *** 51,60 **** --- 58,76 ---- sjis_cstowcs, }; + #ifdef SVR4 + #define WC_MASK 0x30000000 + #define CS1_WC_MASK 0x30000000 + #define CS2_WC_MASK 0x10000000 + #define CS3_WC_MASK 0x20000000 + #define SHIFT_BITS 7 + #else #define WC_MASK 0x8080 #define CS1_WC_MASK 0x8080 #define CS2_WC_MASK 0x0080 #define CS3_WC_MASK 0x8000 + #define SHIFT_BITS 8 + #endif #ifndef iskanji #define iskanji(x) ((0x81<=(x) && (x)<=0x9f) || (0xe0<=(x) && (x)<=0xfc)) *************** *** 63,87 **** #define iskana(x) (0xa1<=(x) && (x)<=0xdf) #endif /* !iskana */ - static void - null_proc(lcd) - Ximp_XLCd lcd; - { - } ! static Bool ! sjis_initialize(lcd) ! Ximp_XLCd lcd; { ! lcd->ximp_lcpart->mb_cur_max = 2; ! lcd->ximp_lcpart->state_dependent = False; ! return True; } static char ! sjis_mbchar(lcd, str, lenp) ! Ximp_XLCd lcd; register char *str; register int *lenp; { --- 79,112 ---- #define iskana(x) (0xa1<=(x) && (x)<=0xdf) #endif /* !iskana */ ! XLCd ! _XlcSJISLoader(name) ! char *name; { ! XimpLCd lcd; ! lcd = _XlcCreateLC(name, &lcd_methods, &sjis_lc_methods); ! if (lcd == NULL) ! return (XLCd) NULL; ! ! if (strcmp(lcd->locale.codeset, "SJIS")) ! goto error; ! ! if (_XlcLoadCodeSet(lcd) == False) ! goto error; ! ! return (XLCd) lcd; ! ! error: ! _XlcDestroyLC(lcd); ! ! return (XLCd) NULL; } static char ! sjis_mbchar(state, str, lenp) ! State state; register char *str; register int *lenp; { *************** *** 96,109 **** } static int ! sjis_mbstocs(lcd, mbstr, mbstr_len, csbuf, csbuf_len, cs_number, char_length) ! Ximp_XLCd lcd; unsigned char *mbstr; int mbstr_len; unsigned char *csbuf; int *csbuf_len; - int *cs_number; - int *char_length; { register unsigned char *mbptr = mbstr; register unsigned char *bufptr = csbuf; --- 121,132 ---- } static int ! sjis_mbstocs(state, mbstr, mbstr_len, csbuf, csbuf_len) ! State state; unsigned char *mbstr; int mbstr_len; unsigned char *csbuf; int *csbuf_len; { register unsigned char *mbptr = mbstr; register unsigned char *bufptr = csbuf; *************** *** 115,132 **** buf_len = *csbuf_len; else buf_len = MAXINT; - if (char_length) - *char_length = 1; - ch = *mbptr; if (ch & 0x80) { ! if (iskanji(ch)) { codeset_number = 1; ! if (char_length) ! *char_length = 2; ! } else if (iskana(ch)) codeset_number = 2; } while (mbstr_len > 0 && buf_len > 0) { ch = *mbptr; --- 138,151 ---- buf_len = *csbuf_len; else buf_len = MAXINT; ch = *mbptr; if (ch & 0x80) { ! if (iskanji(ch)) codeset_number = 1; ! else if (iskana(ch)) codeset_number = 2; } + state->codeset = state->lcd->locale.codeset_list[codeset_number]; while (mbstr_len > 0 && buf_len > 0) { ch = *mbptr; *************** *** 162,169 **** if (csbuf_len) *csbuf_len = bufptr - csbuf; - if (cs_number) - *cs_number = codeset_number; return mbptr - mbstr; } --- 181,186 ---- *************** *** 170,183 **** static int ! sjis_wcstocs(lcd, wcstr, wcstr_len, csbuf, csbuf_len, cs_number, char_length) ! Ximp_XLCd lcd; wchar_t *wcstr; int wcstr_len; unsigned char *csbuf; int *csbuf_len; - int *cs_number; - int *char_length; { wchar_t *wcptr = wcstr, wc_mask; register unsigned char *bufptr = csbuf; --- 187,198 ---- static int ! sjis_wcstocs(state, wcstr, wcstr_len, csbuf, csbuf_len) ! State state; wchar_t *wcstr; int wcstr_len; unsigned char *csbuf; int *csbuf_len; { wchar_t *wcptr = wcstr, wc_mask; register unsigned char *bufptr = csbuf; *************** *** 184,190 **** register wchar_t wch; int buf_len; int codeset_number = 0; ! #ifdef sony_news unsigned char ch, ch2; #endif --- 199,205 ---- register wchar_t wch; int buf_len; int codeset_number = 0; ! #if defined(sony_news) && !defined(__svr4) unsigned char ch, ch2; #endif *************** *** 192,210 **** buf_len = *csbuf_len; else buf_len = MAXINT; - if (char_length) - *char_length = 1; - wch = *wcptr; ! #ifdef sony_news ch = (unsigned char) (wch >> 8); ch2 = (unsigned char) wch; if (ch) { codeset_number = 1; - if (char_length) - *char_length = 2; } else if (iskana(ch2)) codeset_number = 2; for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) { wch = *wcptr; --- 207,221 ---- buf_len = *csbuf_len; else buf_len = MAXINT; wch = *wcptr; ! #if defined(sony_news) && !defined(__svr4) ch = (unsigned char) (wch >> 8); ch2 = (unsigned char) wch; if (ch) { codeset_number = 1; } else if (iskana(ch2)) codeset_number = 2; + state->codeset = state->lcd->locale.codeset_list[codeset_number]; for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) { wch = *wcptr; *************** *** 238,247 **** wc_mask = wch & WC_MASK; if (wc_mask == CS1_WC_MASK) { codeset_number = 1; - if (char_length) - *char_length = 2; } else if (wc_mask == CS2_WC_MASK) codeset_number = 2; for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) { wch = *wcptr; --- 249,257 ---- wc_mask = wch & WC_MASK; if (wc_mask == CS1_WC_MASK) { codeset_number = 1; } else if (wc_mask == CS2_WC_MASK) codeset_number = 2; + state->codeset = state->lcd->locale.codeset_list[codeset_number]; for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) { wch = *wcptr; *************** *** 268,293 **** if (csbuf_len) *csbuf_len = bufptr - csbuf; - if (cs_number) - *cs_number = codeset_number; - return wcptr - wcstr; } static int ! sjis_cstombs(lcd, csstr, csstr_len, mbbuf, mbbuf_len, cs_number) ! Ximp_XLCd lcd; unsigned char *csstr; int csstr_len; unsigned char *mbbuf; int *mbbuf_len; - int cs_number; { register unsigned char *csptr = csstr; register unsigned char *bufptr = mbbuf; unsigned char high, low, ch1, ch2; register buf_len; if (mbbuf_len) buf_len = *mbbuf_len; --- 278,300 ---- if (csbuf_len) *csbuf_len = bufptr - csbuf; return wcptr - wcstr; } static int ! sjis_cstombs(state, csstr, csstr_len, mbbuf, mbbuf_len) ! State state; unsigned char *csstr; int csstr_len; unsigned char *mbbuf; int *mbbuf_len; { register unsigned char *csptr = csstr; register unsigned char *bufptr = mbbuf; unsigned char high, low, ch1, ch2; register buf_len; + int cs_num = state->codeset->cs_num; if (mbbuf_len) buf_len = *mbbuf_len; *************** *** 296,302 **** if (csstr_len < buf_len) buf_len = csstr_len; ! if (cs_number == 1) { buf_len >>= 1; while (buf_len--) { high = *csptr++ & 0x7f; --- 303,309 ---- if (csstr_len < buf_len) buf_len = csstr_len; ! if (cs_num == 1) { buf_len >>= 1; while (buf_len--) { high = *csptr++ & 0x7f; *************** *** 314,320 **** *bufptr++ = ch1; *bufptr++ = ch2; } ! } else if(cs_number == 2) { while (buf_len--) *bufptr++ = *csptr++ | 0x80; } else --- 321,327 ---- *bufptr++ = ch1; *bufptr++ = ch2; } ! } else if(cs_num == 2) { while (buf_len--) *bufptr++ = *csptr++ | 0x80; } else *************** *** 329,347 **** static int ! sjis_cstowcs(lcd, csstr, csstr_len, wcbuf, wcbuf_len, cs_number) ! Ximp_XLCd lcd; unsigned char *csstr; int csstr_len; wchar_t *wcbuf; int *wcbuf_len; - int cs_number; { register unsigned char *csptr = csstr; wchar_t *bufptr = wcbuf; register wchar_t wch; register buf_len; ! #ifdef sony_news unsigned char high, low, ch1, ch2; #endif --- 336,354 ---- static int ! sjis_cstowcs(state, csstr, csstr_len, wcbuf, wcbuf_len) ! State state; unsigned char *csstr; int csstr_len; wchar_t *wcbuf; int *wcbuf_len; { register unsigned char *csptr = csstr; wchar_t *bufptr = wcbuf; register wchar_t wch; register buf_len; ! int cs_num = state->codeset->cs_num; ! #if defined(sony_news) && !defined(__svr4) unsigned char high, low, ch1, ch2; #endif *************** *** 350,357 **** else buf_len = MAXINT; ! #ifdef sony_news ! if (cs_number == 1) { csstr_len >>= 1; if (csstr_len < buf_len) buf_len = csstr_len; --- 357,364 ---- else buf_len = MAXINT; ! #if defined(sony_news) && !defined(__svr4) ! if (cs_num == 1) { csstr_len >>= 1; if (csstr_len < buf_len) buf_len = csstr_len; *************** *** 370,376 **** ch2 = low + 0x7e; *bufptr++ = (ch1 << 8) | ch2; } ! } else if (cs_number == 2) { if (csstr_len < buf_len) buf_len = csstr_len; while (buf_len--) --- 377,383 ---- ch2 = low + 0x7e; *bufptr++ = (ch1 << 8) | ch2; } ! } else if (cs_num == 2) { if (csstr_len < buf_len) buf_len = csstr_len; while (buf_len--) *************** *** 381,388 **** while (buf_len--) *bufptr++ = (wchar_t) (*csptr++ & 0x7f); } ! #else ! if (cs_number == 1) { csstr_len >>= 1; if (csstr_len < buf_len) buf_len = csstr_len; --- 388,395 ---- while (buf_len--) *bufptr++ = (wchar_t) (*csptr++ & 0x7f); } ! #else /* defined(sony_news) && !defined(__svr4) */ ! if (cs_num == 1) { csstr_len >>= 1; if (csstr_len < buf_len) buf_len = csstr_len; *************** *** 389,402 **** while (buf_len--) { wch = *csptr++; ! wch = (wch << 8) | *csptr++; *bufptr++ = wch | CS1_WC_MASK; } ! } else if (cs_number == 2) { if (csstr_len < buf_len) buf_len = csstr_len; while (buf_len--) ! *bufptr++ = (wchar_t) (*csptr++ | CS2_WC_MASK); } else { if (csstr_len < buf_len) buf_len = csstr_len; --- 396,409 ---- while (buf_len--) { wch = *csptr++; ! wch = (wch << SHIFT_BITS) | *csptr++; *bufptr++ = wch | CS1_WC_MASK; } ! } else if (cs_num == 2) { if (csstr_len < buf_len) buf_len = csstr_len; while (buf_len--) ! *bufptr++ = (wchar_t) ((*csptr++ & 0x7f) | CS2_WC_MASK); } else { if (csstr_len < buf_len) buf_len = csstr_len; *************** *** 403,409 **** while (buf_len--) *bufptr++ = (wchar_t) (*csptr++ & 0x7f); } ! #endif if (wcbuf_len) *wcbuf_len = bufptr - wcbuf; --- 410,416 ---- while (buf_len--) *bufptr++ = (wchar_t) (*csptr++ & 0x7f); } ! #endif /* defined(sony_news) && !defined(__svr4) */ if (wcbuf_len) *wcbuf_len = bufptr - wcbuf; *** /tmp/d04004 Tue Mar 9 09:23:08 1993 --- mit/lib/X/Ximp/XimpTxtEsc.c Tue Mar 9 09:23:06 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpTxtEsc.c,v 1.2 92/04/14 13:30:02 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpTxtEsc.c,v 1.3 92/10/19 19:26:24 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 71,95 **** */ { ! Ximp_XLCd lcd = (Ximp_XLCd) xfont_set->core.lcd; unsigned char *strptr, strbuf[BUFSIZE]; unsigned char xchar_buf[BUFSIZE]; XChar2b xchar2b_buf[BUFSIZE]; - FontSetRec *fontset; XFontStruct *font; int (*cnv_func)(); - int cset_num, char_length; int count, length, tmp_len; int width = 0; ! cnv_func = lcd->ximp_lcpart->methods->CNV_FUNC; ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); while (text_length > 0) { length = BUFSIZE; ! count = (*cnv_func)(lcd, text, text_length, strbuf, &length, ! &cset_num, &char_length); if (count <= 0) break; --- 71,95 ---- */ { ! XLCd lcd = xfont_set->core.lcd; unsigned char *strptr, strbuf[BUFSIZE]; unsigned char xchar_buf[BUFSIZE]; XChar2b xchar2b_buf[BUFSIZE]; XFontStruct *font; int (*cnv_func)(); int count, length, tmp_len; int width = 0; + LCMethods methods = LC_METHODS(lcd); + State state; ! cnv_func = methods->CNV_FUNC; ! state = (*methods->create_state)(lcd); ! (*methods->cnv_start)(state); while (text_length > 0) { length = BUFSIZE; ! count = (*cnv_func)(state, text, text_length, strbuf, &length); if (count <= 0) break; *************** *** 97,117 **** text_length -= count; strptr = strbuf; - fontset = ((Ximp_XFontSet) xfont_set)->ximp_fspart->fontset + cset_num; - if (fontset == NULL) - continue; while (length > 0) { tmp_len = BUFSIZE; ! if (char_length < 2) ! count = _Ximp_cstoxchar(fontset, strptr, length, ! xchar_buf, &tmp_len, &font); else ! count = _Ximp_cstoxchar2b(fontset, strptr, length, ! xchar2b_buf, &tmp_len, &font); if (count <= 0) break; ! if (char_length < 2) width += XTextWidth(font, (char *)xchar_buf, tmp_len); else width += XTextWidth16(font, xchar2b_buf, tmp_len); --- 97,114 ---- text_length -= count; strptr = strbuf; while (length > 0) { tmp_len = BUFSIZE; ! if (state->codeset->length < 2) ! count = _Ximp_cstoxchar(xfont_set, strptr, length, xchar_buf, ! &tmp_len, state->codeset, &font); else ! count = _Ximp_cstoxchar2b(xfont_set, strptr, length, xchar2b_buf, ! &tmp_len, state->codeset, &font); if (count <= 0) break; ! if (state->codeset->length < 2) width += XTextWidth(font, (char *)xchar_buf, tmp_len); else width += XTextWidth16(font, xchar2b_buf, tmp_len); *************** *** 121,127 **** } } ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); return width; } --- 118,125 ---- } } ! (*methods->cnv_end)(state); ! (*methods->destroy_state)(state); return width; } *** /tmp/d04026 Tue Mar 9 09:23:19 1993 --- mit/lib/X/Ximp/XimpTxtExt.c Tue Mar 9 09:23:17 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpTxtExt.c,v 1.4 92/04/14 13:30:06 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpTxtExt.c,v 1.5 92/10/19 19:26:28 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 71,92 **** */ { ! Ximp_XLCd lcd = (Ximp_XLCd) xfont_set->core.lcd; unsigned char *strptr, strbuf[BUFSIZE]; unsigned char xchar_buf[BUFSIZE]; XChar2b xchar2b_buf[BUFSIZE]; - FontSetRec *fontset; XFontStruct *font; int (*cnv_func)(); - int cset_num, char_length; int count, length, tmp_len; int direction, logical_ascent, logical_descent, tmp_ascent, tmp_descent; XCharStruct overall, tmp_overall; Bool first = True; ! cnv_func = lcd->ximp_lcpart->methods->CNV_FUNC; ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); bzero(&overall, sizeof(XCharStruct)); logical_ascent = logical_descent = 0; --- 71,93 ---- */ { ! XLCd lcd = xfont_set->core.lcd; unsigned char *strptr, strbuf[BUFSIZE]; unsigned char xchar_buf[BUFSIZE]; XChar2b xchar2b_buf[BUFSIZE]; XFontStruct *font; int (*cnv_func)(); int count, length, tmp_len; int direction, logical_ascent, logical_descent, tmp_ascent, tmp_descent; XCharStruct overall, tmp_overall; Bool first = True; + LCMethods methods = LC_METHODS(lcd); + State state; ! cnv_func = methods->CNV_FUNC; ! state = (*methods->create_state)(lcd); ! (*methods->cnv_start)(state); bzero(&overall, sizeof(XCharStruct)); logical_ascent = logical_descent = 0; *************** *** 93,100 **** while (text_length > 0) { length = BUFSIZE; ! count = (*cnv_func)(lcd, text, text_length, strbuf, &length, ! &cset_num, &char_length); if (count <= 0) break; --- 94,100 ---- while (text_length > 0) { length = BUFSIZE; ! count = (*cnv_func)(state, text, text_length, strbuf, &length); if (count <= 0) break; *************** *** 102,122 **** text_length -= count; strptr = strbuf; - fontset = ((Ximp_XFontSet) xfont_set)->ximp_fspart->fontset + cset_num; - if (fontset == NULL) - continue; while (length > 0) { tmp_len = BUFSIZE; ! if (char_length < 2) ! count = _Ximp_cstoxchar(fontset, strptr, length, ! xchar_buf, &tmp_len, &font); else ! count = _Ximp_cstoxchar2b(fontset, strptr, length, ! xchar2b_buf, &tmp_len, &font); if (count <= 0) break; ! if (char_length < 2) XTextExtents(font, (char *)xchar_buf, tmp_len, &direction, &tmp_ascent, &tmp_descent, &tmp_overall); else --- 102,119 ---- text_length -= count; strptr = strbuf; while (length > 0) { tmp_len = BUFSIZE; ! if (state->codeset->length < 2) ! count = _Ximp_cstoxchar(xfont_set, strptr, length, xchar_buf, ! &tmp_len, state->codeset, &font); else ! count = _Ximp_cstoxchar2b(xfont_set, strptr, length, xchar2b_buf, ! &tmp_len, state->codeset, &font); if (count <= 0) break; ! if (state->codeset->length < 2) XTextExtents(font, (char *)xchar_buf, tmp_len, &direction, &tmp_ascent, &tmp_descent, &tmp_overall); else *************** *** 145,151 **** } } ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); if (overall_ink) { overall_ink->x = overall.lbearing; --- 142,149 ---- } } ! (*methods->cnv_end)(state); ! (*methods->destroy_state)(state); if (overall_ink) { overall_ink->x = overall.lbearing; *** /tmp/d04048 Tue Mar 9 09:23:32 1993 --- mit/lib/X/Ximp/XimpTxtPer.c Tue Mar 9 09:23:28 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpTxtPer.c,v 1.4 92/04/14 13:30:08 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpTxtPer.c,v 1.5 92/10/19 19:26:31 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 71,92 **** */ { ! Ximp_XLCd lcd = (Ximp_XLCd) xfont_set->core.lcd; unsigned char *strptr, strbuf[BUFSIZE]; unsigned char *xchar_ptr, xchar_buf[BUFSIZE]; XChar2b *xchar2b_ptr, xchar2b_buf[BUFSIZE]; - FontSetRec *fontset; XFontStruct *font; XCharStruct *def, *cs, overall; int (*cnv_func)(); - int cset_num, char_length; int count, length, tmp_len, require_num; int logical_ascent, logical_descent; Bool first = True; ! cnv_func = lcd->ximp_lcpart->methods->CNV_FUNC; ! (*lcd->ximp_lcpart->methods->cnv_start)(lcd); bzero(&overall, sizeof(XCharStruct)); logical_ascent = logical_descent = require_num = *num_chars = 0; --- 71,93 ---- */ { ! XLCd lcd = xfont_set->core.lcd; unsigned char *strptr, strbuf[BUFSIZE]; unsigned char *xchar_ptr, xchar_buf[BUFSIZE]; XChar2b *xchar2b_ptr, xchar2b_buf[BUFSIZE]; XFontStruct *font; XCharStruct *def, *cs, overall; int (*cnv_func)(); int count, length, tmp_len, require_num; int logical_ascent, logical_descent; Bool first = True; + LCMethods methods = LC_METHODS(lcd); + State state; ! cnv_func = methods->CNV_FUNC; ! state = (*methods->create_state)(lcd); ! (*methods->cnv_start)(state); bzero(&overall, sizeof(XCharStruct)); logical_ascent = logical_descent = require_num = *num_chars = 0; *************** *** 93,100 **** while (text_length > 0) { length = BUFSIZE; ! count = (*cnv_func)(lcd, text, text_length, strbuf, &length, ! &cset_num, &char_length); if (count <= 0) break; --- 94,100 ---- while (text_length > 0) { length = BUFSIZE; ! count = (*cnv_func)(state, text, text_length, strbuf, &length); if (count <= 0) break; *************** *** 102,118 **** text_length -= count; strptr = strbuf; - fontset = ((Ximp_XFontSet) xfont_set)->ximp_fspart->fontset + cset_num; - if (fontset == NULL) - continue; while (length > 0) { tmp_len = BUFSIZE; ! if (char_length < 2) ! count = _Ximp_cstoxchar(fontset, strptr, length, ! xchar_buf, &tmp_len, &font); else ! count = _Ximp_cstoxchar2b(fontset, strptr, length, ! xchar2b_buf, &tmp_len, &font); if (count <= 0) break; --- 102,115 ---- text_length -= count; strptr = strbuf; while (length > 0) { tmp_len = BUFSIZE; ! if (state->codeset->length < 2) ! count = _Ximp_cstoxchar(xfont_set, strptr, length, xchar_buf, ! &tmp_len, state->codeset, &font); else ! count = _Ximp_cstoxchar2b(xfont_set, strptr, length, xchar2b_buf, ! &tmp_len, state->codeset, &font); if (count <= 0) break; *************** *** 120,132 **** length -= count; if (require_num) { ! require_num += count; continue; } if (buf_size < tmp_len) { ! require_num = *num_chars + count; continue; } if (first) { logical_ascent = font->ascent; --- 117,130 ---- length -= count; if (require_num) { ! require_num += tmp_len; continue; } if (buf_size < tmp_len) { ! require_num = *num_chars + tmp_len; continue; } + buf_size -= tmp_len; if (first) { logical_ascent = font->ascent; *************** *** 136,142 **** logical_descent = max(logical_descent, font->descent); } ! if (char_length < 2) { CI_GET_DEFAULT_INFO_1D (font, def) xchar_ptr = xchar_buf; } else { --- 134,140 ---- logical_descent = max(logical_descent, font->descent); } ! if (state->codeset->length < 2) { CI_GET_DEFAULT_INFO_1D (font, def) xchar_ptr = xchar_buf; } else { *************** *** 145,151 **** } while (tmp_len-- > 0) { ! if (char_length < 2) { CI_GET_CHAR_INFO_1D (font, *xchar_ptr, def, cs) xchar_ptr++; } else { --- 143,149 ---- } while (tmp_len-- > 0) { ! if (state->codeset->length < 2) { CI_GET_CHAR_INFO_1D (font, *xchar_ptr, def, cs) xchar_ptr++; } else { *************** *** 186,192 **** } } ! (*lcd->ximp_lcpart->methods->cnv_end)(lcd); if (require_num) { *num_chars = require_num; --- 184,191 ---- } } ! (*methods->cnv_end)(state); ! (*methods->destroy_state)(state); if (require_num) { *num_chars = require_num; *** /tmp/d04072 Tue Mar 9 09:23:50 1993 --- mit/lib/X/Ximp/XimpTxtPr.c Tue Mar 9 09:23:44 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpTxtPr.c,v 1.3 92/04/14 13:30:11 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpTxtPr.c,v 1.4 92/10/19 19:26:35 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 70,76 **** */ { ! Ximp_XLCd lcd; unsigned char *value, *buf, *buf_ptr; Atom encoding; int nitems, unconv_num; --- 70,76 ---- */ { ! XLCd lcd; unsigned char *value, *buf, *buf_ptr; Atom encoding; int nitems, unconv_num; *************** *** 77,83 **** int tmp_len, tmp_num; int (*cnv_func)(); ! if ((lcd = (Ximp_XLCd) _XlcCurrentLC()) == NULL) return XLocaleNotSupported; switch (style) { --- 77,83 ---- int tmp_len, tmp_num; int (*cnv_func)(); ! if ((lcd = _XlcCurrentLC()) == NULL) return XLocaleNotSupported; switch (style) { *** /tmp/d04094 Tue Mar 9 09:24:03 1993 --- mit/lib/X/Ximp/XimpWPer.c Tue Mar 9 09:23:59 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpWPer.c,v 1.2 92/04/14 13:30:27 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpWPer.c,v 1.3 92/10/19 19:26:52 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 73,79 **** _Ximp_wc_extents_per_char(xfont_set, text, text_length, ink_buf, logical_buf, buf_size, num_chars, overall_ink, overall_logical) XFontSet xfont_set; ! char *text; int text_length; XRectangle *ink_buf; XRectangle *logical_buf; --- 73,79 ---- _Ximp_wc_extents_per_char(xfont_set, text, text_length, ink_buf, logical_buf, buf_size, num_chars, overall_ink, overall_logical) XFontSet xfont_set; ! wchar_t *text; int text_length; XRectangle *ink_buf; XRectangle *logical_buf; *** /tmp/d04116 Tue Mar 9 09:24:15 1993 --- mit/lib/X/Ximp/XimpWPrTxt.c Tue Mar 9 09:24:12 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpWPrTxt.c,v 1.3 92/04/14 13:30:30 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpWPrTxt.c,v 1.4 92/10/19 19:26:56 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 70,80 **** #include #include ! extern int _Ximp_mbstowcs(), _Ximp_cttowcs(); extern wchar_t *_Xwcscpy(); int XwcTextPropertyToTextList(dpy, text_prop, list_ret, count_ret) Display *dpy; XTextProperty *text_prop; wchar_t ***list_ret; --- 70,85 ---- #include #include ! extern int _Xlc_mbstowcs(), _Ximp_cttowcs(); extern wchar_t *_Xwcscpy(); int + #ifndef DYNAMICLIB XwcTextPropertyToTextList(dpy, text_prop, list_ret, count_ret) + #else + _XimpwcTextPropertyToTextList(lcd, dpy, text_prop, list_ret, count_ret) + XLCd lcd; + #endif Display *dpy; XTextProperty *text_prop; wchar_t ***list_ret; *************** *** 84,92 **** wchar_t *buf, *buf_ptr; unsigned char *str_ptr; int i, count, unconv_num, tmp_len, buf_len; ! #define CNV_STR_FUNC _Ximp_mbstowcs #define CNV_CTEXT_FUNC _Ximp_cttowcs ! #define CNV_TEXT_FUNC _Ximp_mbstowcs /* XXX */ buf_len = text_prop->nitems + 1; --- 89,97 ---- wchar_t *buf, *buf_ptr; unsigned char *str_ptr; int i, count, unconv_num, tmp_len, buf_len; ! #define CNV_STR_FUNC _Xlc_mbstowcs #define CNV_CTEXT_FUNC _Ximp_cttowcs ! #define CNV_TEXT_FUNC _Xlc_mbstowcs /* XXX */ buf_len = text_prop->nitems + 1; *************** *** 124,130 **** return unconv_num; } ! void XwcFreeStringList(list) wchar_t **list; { if (list) { --- 129,141 ---- return unconv_num; } ! void ! #ifndef DYNAMICLIB ! XwcFreeStringList(list) ! #else ! _XimpwcFreeStringList(lcd, list) ! XLCd lcd ; ! #endif wchar_t **list; { if (list) { *** /tmp/d04139 Tue Mar 9 09:24:28 1993 --- mit/lib/X/Ximp/XimpWTxtPr.c Tue Mar 9 09:24:24 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpWTxtPr.c,v 1.3 92/04/14 13:30:33 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpWTxtPr.c,v 1.4 92/10/19 19:26:59 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 70,80 **** #include #include ! extern int _Ximp_wcstostring(), _Ximp_wcstoct(), _Ximp_wcstombs(); extern int _Xwcslen(); int XwcTextListToTextProperty(dpy, list, count, style, text_prop) Display *dpy; wchar_t **list; int count; --- 70,85 ---- #include #include ! extern int _Ximp_wcstostring(), _Ximp_wcstoct(), _Xlc_wcstombs(); extern int _Xwcslen(); int + #ifndef DYNAMICLIB XwcTextListToTextProperty(dpy, list, count, style, text_prop) + #else + _XimpwcTextListToTextProperty(lcd, dpy, list, count, style, text_prop) + XLCd lcd; + #endif Display *dpy; wchar_t **list; int count; *************** *** 86,92 **** #define CNV_STR_FUNC _Ximp_wcstostring #define CNV_CTEXT_FUNC _Ximp_wcstoct ! #define CNV_TEXT_FUNC _Ximp_wcstombs #define STRLEN_FUNC _Xwcslen /* XXX */ --- 91,97 ---- #define CNV_STR_FUNC _Ximp_wcstostring #define CNV_CTEXT_FUNC _Ximp_wcstoct ! #define CNV_TEXT_FUNC _Xlc_wcstombs #define STRLEN_FUNC _Xwcslen /* XXX */ *** /tmp/d04162 Tue Mar 9 09:24:41 1993 --- mit/lib/X/Ximp/XimpXConv.c Tue Mar 9 09:24:38 1993 *************** *** 1,4 **** ! /* $XConsortium: XimpXConv.c,v 1.3 92/04/14 13:30:36 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. --- 1,4 ---- ! /* $XConsortium: XimpXConv.c,v 1.4 92/10/19 19:27:02 rws Exp $ */ /* * Copyright 1990, 1991, 1992 by TOSHIBA Corp. * Copyright 1990, 1991, 1992 by SORD Computer Corp. *************** *** 69,145 **** #include "Xlcint.h" #include "Ximplc.h" ! static XFontStruct * ! getFont(fontset, str, xstr) ! FontSetRec *fontset; ! unsigned char *str; ! unsigned char *xstr; { ! register ExtFontRec *ext_font = fontset->ext_font_list; ! int ext_font_num = fontset->ext_font_num; ! register unsigned char ch; ! unsigned char ch_L, ch_R; ! ch_L = *str & 0x7f; ! ch_R = ch_L | 0x80; ! while (ext_font_num--) { ! ch = ext_font->msb_mask ? ch_R : ch_L; ! if (ch > ext_font->min_char && ch < ext_font->max_char) { ! *xstr = ch; ! return ext_font->font; ! } ! ext_font++; ! } ! ! *xstr = fontset->msb_mask ? ch_R : ch_L; ! ! return fontset->font; } - static XFontStruct * - getFont16(fontset, str, xstr) - FontSetRec *fontset; - unsigned char *str; - XChar2b *xstr; - { - register ExtFontRec *ext_font = fontset->ext_font_list; - int ext_font_num = fontset->ext_font_num; - register unsigned xchar; - unsigned xchar_L, xchar_R; - - xchar_L = ((unsigned) *str << 8 | *(str+1)) & 0x7f7f; - xchar_R = xchar_L | 0x8080; - - while (ext_font_num--) { - xchar = ext_font->msb_mask ? xchar_R : xchar_L; - if (xchar > ext_font->min_char && xchar < ext_font->max_char) - goto done; - ext_font++; - } - - xchar = ext_font->msb_mask ? xchar_R : xchar_L; - done: - xstr->byte1 = xchar >> 8; - xstr->byte2 = (unsigned char) xchar; - - return fontset->font; - } - int ! _Ximp_cstoxchar(fontset, string, length, ret_buf, ret_len, ret_font) ! FontSetRec *fontset; unsigned char *string; register int length; unsigned char *ret_buf; int *ret_len; XFontStruct **ret_font; { register unsigned char mask, *strptr = string; register unsigned char *bufptr = ret_buf; XFontStruct *font; ! if (fontset->font == NULL) return -1; if (length > *ret_len) --- 69,106 ---- #include "Xlcint.h" #include "Ximplc.h" ! static FontSetRec * ! GetFontSetFromCodeSet(xfont_set, codeset) ! XimpFontSet xfont_set; ! CodeSet codeset; { ! FontSetRec *fontset = xfont_set->ximp_fspart.fontset; ! int num = xfont_set->ximp_fspart.fontset_num; ! for ( ; num-- > 0; fontset++) ! if (fontset->codeset == codeset) ! return fontset; ! return (FontSetRec *) NULL; } int ! _Ximp_cstoxchar(xfont_set, string, length, ret_buf, ret_len, codeset, ret_font) ! XFontSet xfont_set; unsigned char *string; register int length; unsigned char *ret_buf; int *ret_len; + CodeSet codeset; XFontStruct **ret_font; { register unsigned char mask, *strptr = string; register unsigned char *bufptr = ret_buf; + FontSetRec *fontset; XFontStruct *font; ! fontset = GetFontSetFromCodeSet(xfont_set, codeset); ! if (fontset == NULL || fontset->font == NULL) return -1; if (length > *ret_len) *************** *** 147,170 **** if (length < 1) return 0; ! if (fontset->ext_font_num == 0) { ! font = fontset->font; ! mask = fontset->msb_mask; ! while (length--) ! *bufptr++ = (*strptr++ & 0x7f) | mask; ! goto done; ! } - font = getFont(fontset, strptr, bufptr); - strptr++; - bufptr++; - length--; - - for ( ; length > 0; length--, strptr++, bufptr++) - if (font != getFont(fontset, strptr, bufptr)) - break; - - done: *ret_len = bufptr - ret_buf; *ret_font = font; --- 108,118 ---- if (length < 1) return 0; ! font = fontset->font; ! mask = fontset->side; ! while (length--) ! *bufptr++ = (*strptr++ & 0x7f) | mask; *ret_len = bufptr - ret_buf; *ret_font = font; *************** *** 172,190 **** } int ! _Ximp_cstoxchar2b(fontset, string, length, ret_buf, ret_len, ret_font) ! FontSetRec *fontset; unsigned char *string; register int length; XChar2b *ret_buf; int *ret_len; XFontStruct **ret_font; { register unsigned char mask, *strptr = string; register XChar2b *bufptr = ret_buf; XFontStruct *font; ! if (fontset->font == NULL) return -1; length >>= 1; --- 120,141 ---- } int ! _Ximp_cstoxchar2b(xfont_set, string, length, ret_buf, ret_len, codeset, ret_font) ! XFontSet xfont_set; unsigned char *string; register int length; XChar2b *ret_buf; int *ret_len; + CodeSet codeset; XFontStruct **ret_font; { register unsigned char mask, *strptr = string; register XChar2b *bufptr = ret_buf; + FontSetRec *fontset; XFontStruct *font; ! fontset = GetFontSetFromCodeSet(xfont_set, codeset); ! if (fontset == NULL || fontset->font == NULL) return -1; length >>= 1; *************** *** 193,219 **** if (length < 1) return 0; ! if (fontset->ext_font_num == 0) { ! font = fontset->font; ! mask = fontset->msb_mask; ! while (length--) { ! bufptr->byte1 = (*strptr++ & 0x7f) | mask; ! bufptr->byte2 = (*strptr++ & 0x7f) | mask; ! bufptr++; ! } ! goto done; } - font = getFont16(fontset, strptr, bufptr); - strptr += 2; - bufptr++; - length--; - - for ( ; length > 0; length--, strptr += 2, bufptr++) - if (font != getFont16(fontset, strptr, bufptr)) - break; - - done: *ret_len = bufptr - ret_buf; *ret_font = font; --- 144,157 ---- if (length < 1) return 0; ! font = fontset->font; ! mask = fontset->side; ! while (length--) { ! bufptr->byte1 = (*strptr++ & 0x7f) | mask; ! bufptr->byte2 = (*strptr++ & 0x7f) | mask; ! bufptr++; } *ret_len = bufptr - ret_buf; *ret_font = font; *** /tmp/d04185 Tue Mar 9 09:24:55 1993 --- mit/lib/X/Ximp/Ximpint.c Tue Mar 9 09:24:52 1993 *************** *** 1,4 **** ! /* $XConsortium: Ximpint.c,v 1.4 92/04/14 13:30:39 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by Fuji Xerox Co.,Ltd. --- 1,4 ---- ! /* $XConsortium: Ximpint.c,v 1.5 92/10/19 19:27:06 rws Exp $ */ /****************************************************************** Copyright 1991, 1992 by Fuji Xerox Co.,Ltd. *************** *** 133,139 **** int i; unsigned char c; ! count = XLookupString(event, buffer, nbytes, &symbol, status); if (keysym) *keysym = symbol; if ((nbytes == 0) || (symbol == NoSymbol)) { return(count); --- 133,139 ---- int i; unsigned char c; ! count = XLookupString(event, (char *)buffer, nbytes, &symbol, status); if (keysym) *keysym = symbol; if ((nbytes == 0) || (symbol == NoSymbol)) { return(count); *************** *** 159,166 **** } #define BUF_SIZE (20) ! static char local_buf[BUF_SIZE]; ! static unsigned char look[BUF_SIZE]; int _Ximp_LookupMBText(ic, event, buffer, nbytes, keysym, status) --- 159,166 ---- } #define BUF_SIZE (20) ! static char local_buf[BUF_SIZE] = {0}; /* Clean up bss */ ! static unsigned char look[BUF_SIZE] = {0}; /* Clean up bss */ int _Ximp_LookupMBText(ic, event, buffer, nbytes, keysym, status) *************** *** 203,208 **** --- 203,215 ---- count = 0; } } + } else if ((count != 1) || (buffer[0] >= 0x80)) { /* not ASCII Encoding */ + bcopy(buffer, look, count); + if (_Ximp_cttombs(ic->core.im->core.lcd, + look, count, + buffer, &count, NULL) < 0) { + count = 0; + } } return(count); } *************** *** 242,250 **** local_buf[local_count] = c; local_count++; count = BUF_SIZE; ! _Ximp_cttowcs(ic->core.im->core.lcd, local_buf, local_count, ! buffer, &count, NULL); } } else if ((count == 1) && (look[0] < 0x80)) { /* ASCII Encoding */ buffer[0] = look[0]; --- 249,259 ---- local_buf[local_count] = c; local_count++; count = BUF_SIZE; ! if (_Ximp_cttowcs(ic->core.im->core.lcd, local_buf, local_count, ! buffer, &count, NULL) < 0) { ! count = 0; ! } } } else if ((count == 1) && (look[0] < 0x80)) { /* ASCII Encoding */ buffer[0] = look[0]; *** /dev/null Tue Mar 9 09:24:57 1993 --- mit/lib/X/Ximp/XimpLocal.c Tue Mar 9 09:25:04 1993 *************** *** 0 **** --- 1,1224 ---- + /* $XConsortium: XimpLocal.c,v 1.1 92/10/19 19:25:03 rws Exp $ */ + /****************************************************************** + + Copyright 1992 by Fuji Xerox Co., Ltd. + + Permission to use, copy, modify, distribute, and sell this software + and its documentation for any purpose is hereby granted without fee, + provided that the above copyright notice appear in all copies and + that both that copyright notice and this permission notice appear + in supporting documentation, and that the name of Fuji Xerox + not be used in advertising or publicity pertaining to distribution + of the software without specific, written prior permission. + Fuji Xerox make no representations about the suitability of this + software for any purpose. It is provided + "as is" without express or implied warranty. + + FUJI XEROX DISCLAIM ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJI XEROX BE LIABLE + FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA + OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + + Author: Kazunori Nishihara Fuji Xerox + + ******************************************************************/ + + #include + #include + #include + #include + #include + #include + #include "Xlibint.h" + #include "Xlcint.h" + + #include "Ximplc.h" + + static Status _Ximp_Local_CloseIM(); + static char * _Ximp_Local_GetIMValues(); + static XIC _Ximp_Local_CreateIC(); + static void _Ximp_Local_DestroyIC(); + static void _Ximp_Local_SetFocus(); + static void _Ximp_Local_UnSetFocus(); + static char * _Ximp_Local_SetICValues(); + static char * _Ximp_Local_GetICValues(); + static char * _Ximp_Local_MbReset(); + static wchar_t * _Ximp_Local_WcReset(); + static int _Ximp_Local_MbLookupString(); + static int _Ximp_Local_WcLookupString(); + + static Bool _Ximp_PreSetAttributes(); + static Bool _Ximp_StatusSetAttributes(); + static char * _Ximp_SetICValueData(); + + static Bool _Ximp_PreGetAttributes(); + static Bool _Ximp_StatusGetAttributes(); + + extern FILE * _XlcOpenLocaleFile(); + + extern void _Ximp_Local_OpenIM_hook(); + + XIMMethodsRec Ximp_local_im_methods = { + _Ximp_Local_CloseIM, + _Ximp_Local_GetIMValues, + _Ximp_Local_CreateIC + }; + + static XICMethodsRec Ximp_ic_methods = { + _Ximp_Local_DestroyIC, /* destroy */ + _Ximp_Local_SetFocus, /* set_focus */ + _Ximp_Local_UnSetFocus, /* unset_focus */ + _Ximp_Local_SetICValues, /* set_values */ + _Ximp_Local_GetICValues, /* get_values */ + _Ximp_Local_MbReset, /* mb_reset */ + _Ximp_Local_WcReset, /* wc_reset */ + _Ximp_Local_MbLookupString, /* mb_lookup_string */ + _Ximp_Local_WcLookupString, /* wc_lookup_string */ + }; + + static + CreateDefTree(im) + Ximp_XIM im; + { + FILE *fp; + static char *buf[1024]; + char *s, *rhs; + DefTree *elem; + + fp = _XlcOpenLocaleFile(NULL, ((XimpLCd)im->core.lcd)->locale.language, COMPOSE_FILE); + im->ximp_impart->top = (DefTree *)NULL; + if (fp == (FILE *)NULL) return; + #ifdef BACKTRACK_WHEN_UNMATCHED + im->ximp_impart->num_save_rooms = Ximp_ParseStringFile(fp, &im->ximp_impart->top); + #else + (void)Ximp_ParseStringFile(fp, &im->ximp_impart->top); + #endif + fclose(fp); + } + + void + _Ximp_Local_OpenIM_hook(im) + Ximp_XIM im; + { + CreateDefTree(im); + im->ximp_impart->current_ic = (XIC)NULL; + } + + static char * + _Ximp_Local_GetIMValues(im, values) + Ximp_XIM im; + XIMArg *values; + { + XIMArg *p; + XIMStyles **value; + XIMStyles *styles; + int i; + + for (p = values; p->name != NULL; p++) { + if (strcmp(p->name, XNQueryInputStyle) == 0) { + if ((styles = (XIMStyles *)Xmalloc(sizeof(XIMStyles) + + sizeof(XIMStyle) * + im->ximp_impart->im_styles->count_styles)) == NULL) { + break; + } + styles->count_styles = im->ximp_impart->im_styles->count_styles; + styles->supported_styles = (XIMStyle *)(&styles[1]); + for(i=0; i < styles->count_styles; i++) { + styles->supported_styles[i] = im->ximp_impart->im_styles->supported_styles[i]; + } + value = (XIMStyles **)p->value; + *value = styles; + } else { + break; + } + } + return (p->name); + } + + static + FreeDefTreeElements(top) + DefTree *top; + { + if (top->succession) FreeDefTreeElements(top->succession); + if (top->next) FreeDefTreeElements(top->next); + if (top->mb) Xfree(top->mb); + if (top->wc) Xfree(top->wc); + Xfree(top); + } + + static Status + _Ximp_Local_CloseIM(im) + Ximp_XIM im; + { + XIC ic; + + while (ic = im->core.ic_chain) { + XDestroyIC(ic); + } + FreeDefTreeElements(im->ximp_impart->top); + if( im->ximp_impart->im_name ) + XFree( im->ximp_impart->im_name ); + XFree(im->ximp_impart->im_styles->supported_styles); + XFree(im->ximp_impart->im_styles); + XFree(im->ximp_impart); + return (True); + } + + static Bool + _Ximp_Local_Filter(d, w, ev, client_data) + Display *d; + Window w; + XEvent *ev; + XPointer client_data; + { + Ximp_XIC ic = (Ximp_XIC)client_data; + KeySym keysym; + static char buf[128]; + #ifdef BACKTRACK_WHEN_UNMATCHED + static long must_be_through = 0; + #endif + + DefTree *p; + + if (ev->type != KeyPress) return (False); + if (ev->xkey.keycode == 0) return (False); + if (((Ximp_XIM)ic->core.im)->ximp_impart->top == (DefTree *)NULL) return (False); + #ifdef BACKTRACK_WHEN_UNMATCHED + if (must_be_through) { + must_be_through--; + return (False); + } + #endif + + (void)XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL); + if (IsModifierKey(keysym)) return (False); + for (p = ic->ximp_icpart->context; p; p = p->next) { + if (((ev->xkey.state & p->modifier_mask) == p->modifier) && + (keysym == p->keysym)) { + break; + } + } + if (p) { /* Matched */ + if (p->succession) { /* Intermediate */ + ic->ximp_icpart->context = p->succession; + #ifdef BACKTRACK_WHEN_UNMATCHED + /* Seve Event */ + bcopy(ev, &ic->ximp_icpart.saved_event[ic->ximp_icpart.num_saved++], sizeof(XKeyEvent)); + #endif + return (True); + } else { /* Terminate (reached to leaf) */ + ic->ximp_icpart->composed = p; + /* return back to client KeyPressEvent keycode == 0 */ + ev->xkey.keycode = 0; + XPutBackEvent(d, ev); + /* initialize internal state for next key sequence */ + ic->ximp_icpart->context = ((Ximp_XIM)ic->core.im)->ximp_impart->top; + #ifdef BACKTRACK_WHEN_UNMATCHED + ic->ximp_icpart.num_saved = 0; + #endif + return (True); + } + } else { /* Unmatched */ + if (ic->ximp_icpart->context == ((Ximp_XIM)ic->core.im)->ximp_impart->top) { + return (False); + } + /* Error (Sequence Unmatch occured) */ + #ifdef BACKTRACK_WHEN_UNMATCHED + XPutBackEvent(d, ev); + while (ic->ximp_icpart.num_saved > 0) { + ic->ximp_icpart.num_saved--; + XPutBackEvent(d, &ic->ximp_icpart.saved_event[ic->ximp_icpart.num_saved]); + } + must_be_through = 1; + #endif + /* initialize internal state for next key sequence */ + ic->ximp_icpart->context = ((Ximp_XIM)ic->core.im)->ximp_impart->top; + return (True); + } + } + + static XIC + _Ximp_Local_CreateIC(im, values) + XIM im; + XIMArg *values; + { + Ximp_XIC ic; + XICXimpRec *ximp_icpart; + XimpChangeMaskRec dummy; + + if ((ic = (Ximp_XIC)Xmalloc(sizeof(Ximp_XICRec))) == (Ximp_XIC)NULL) { + return ((XIC)NULL); + } + if((ximp_icpart = (XICXimpRec *)Xmalloc(sizeof(XICXimpRec))) == (XICXimpRec *)NULL) { + XFree(ic); + return ((XIC)NULL); + } + bzero((char *)ic, sizeof(Ximp_XICRec)); + bzero((char *)ximp_icpart, sizeof(XICXimpRec)); + + ic->methods = &Ximp_ic_methods; + ic->core.im = im; + ic->core.filter_events = KeyPressMask; + ic->ximp_icpart = ximp_icpart; + ic->ximp_icpart->context = ((Ximp_XIM)im)->ximp_impart->top; + ic->ximp_icpart->composed = NULL; + + if (_Ximp_SetICValueData(ic, values, XIMP_CREATE_IC, &dummy)) { + Xfree(ic); + Xfree(ximp_icpart); + return((XIC)NULL); + } + /* Not Yet */ + if (!(ximp_icpart->value_mask & XIMP_INPUT_STYLE)) { + XFree(ic); + XFree(ximp_icpart); + return ((XIC)NULL); + } + if (ic->core.input_style & XIMPreeditNothing) { + } else if (ic->core.input_style & XIMPreeditNone) { + } else { + } + if (ic->core.input_style & XIMStatusNothing) { + } else if (ic->core.input_style & XIMStatusNone) { + } else { + } + #ifdef BACKTRACK_WHEN_UNMATCHED + if( (ximp_icpart->saved_event = Xcalloc(((Ximp_XIM)im)->ximp_impart->num_save_rooms, sizeof(XEvent))) == NULL ) { + Xfree(ic); + Xfree(ximp_icpart); + return((XIC)NULL); + } + #endif + _XRegisterFilterByType(ic->core.im->core.display, ic->core.focus_window, + KeyPress, KeyPress, _Ximp_Local_Filter, (XPointer)ic); + return ((XIC)ic); + } + + static void + _Ximp_Local_DestroyIC(ic) + Ximp_XIC ic; + { + if (((Ximp_XIM)ic->core.im)->ximp_impart->current_ic == (XIC)ic) { + _Ximp_Local_UnSetFocus(ic); + } + #ifdef BACKTRACK_WHEN_UNMATCHED + Xfree(((XICXimpRec *)ic->ximp_icpart)->saved_event); + #endif + Xfree(ic->ximp_icpart); + return; + } + + static void + _Ximp_Local_SetFocus(ic) + Ximp_XIC ic; + { + XIC current_ic = ((Ximp_XIM)ic->core.im)->ximp_impart->current_ic; + + if (current_ic != (XIC)NULL) { + _Ximp_Local_UnSetFocus(current_ic); + } + ((Ximp_XIM)ic->core.im)->ximp_impart->current_ic = (XIC)ic; + _XRegisterFilterByType(ic->core.im->core.display, ic->core.focus_window, + KeyPress, KeyPress, _Ximp_Local_Filter, (XPointer)ic); + } + + static void + _Ximp_Local_UnSetFocus(ic) + Ximp_XIC ic; + { + ((Ximp_XIM)ic->core.im)->ximp_impart->current_ic = (XIC)NULL; + _XUnregisterFilter (ic->core.im->core.display, ic->core.focus_window, + _Ximp_Local_Filter, (XPointer)ic); + } + + static char * + _Ximp_SetICValues(ic, values) + Ximp_XIC ic; + XIMArg *values; + { + XIM im; + char *ret; + XimpChangeMaskRec change_mask; + + XIMP_SET_NULLMASK(change_mask); + if((ret = _Ximp_SetICValueData(ic, values, XIMP_SET_IC, &change_mask))) + return(ret); + + if( (ic->ximp_icpart->value_mask & XIMP_RES_NAME) + || (ic->ximp_icpart->value_mask & XIMP_RES_CLASS) ) + _Ximp_SetValue_Resource(ic, &change_mask); + return(ret); + } + + static char * + _Ximp_SetICValueData(ic, values, mode, change_mask) + Ximp_XIC ic; + XIMArg *values; + int mode; + XimpChangeaMask change_mask; + { + XIMArg *p; + char *return_name = NULL; + + for(p = values; p->name != NULL; p++) { + if(strcmp(p->name, XNInputStyle) == 0) { + if(mode == XIMP_CREATE_IC) { + ic->core.input_style = (XIMStyle)p->value; + ic->ximp_icpart->value_mask |= XIMP_INPUT_STYLE; + } else { + ; /* Currently Fixed value */ + } + } else if(strcmp(p->name, XNClientWindow)==0) { + if(!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) { + ic->core.client_window = (Window)p->value; + ic->ximp_icpart->value_mask |= XIMP_CLIENT_WIN; + if(!(XIMP_CHK_FOCUSWINMASK(ic))) { + ic->core.focus_window = ic->core.client_window; + XIMP_SET_FOCUSWINMASK2(ic, change_mask); + } + } else { + return_name = p->name; + break; /* Can't change this value */ + } + + } else if(strcmp(p->name, XNFocusWindow)==0) { + ic->ximp_icpart->back_focus_win = ic->core.focus_window; + ic->core.focus_window = (Window)p->value; + XIMP_SET_FOCUSWINMASK2(ic, change_mask); + + } else if(strcmp(p->name, XNResourceName)==0) { + ic->core.im->core.res_name = (char *)p->value; + ic->ximp_icpart->value_mask |= XIMP_RES_NAME; + + } else if(strcmp(p->name, XNResourceClass)==0) { + ic->core.im->core.res_class = (char *)p->value; + ic->ximp_icpart->value_mask |= XIMP_RES_CLASS; + + } else if(strcmp(p->name, XNGeometryCallback)==0) { + ic->core.geometry_callback.client_data = + ((XIMCallback *)p->value)->client_data; + ic->core.geometry_callback.callback = + ((XIMCallback *)p->value)->callback; + ic->ximp_icpart->value_mask |= XIMP_GEOMETRY_CB; + + } else if(strcmp(p->name, XNPreeditAttributes)==0) { + if( _Ximp_PreSetAttributes(ic, + &(ic->ximp_icpart->preedit_attr), + p->value, mode, change_mask, + return_name) == False ) + break; + + } else if(strcmp(p->name, XNStatusAttributes)==0) { + if( _Ximp_StatusSetAttributes(ic, + &(ic->ximp_icpart->status_attr), + p->value, mode, change_mask, + return_name) == False ) + break; + + } else { + return_name = p->name; + break; + } + } + return(return_name); + } + + static Bool + _Ximp_PreSetAttributes(ic, attr, vl, mode, change_mask, return_name) + Ximp_XIC ic; + Ximp_PreeditPropRec4 *attr; + XIMArg *vl; + int mode; + XimpChangeaMask change_mask; + char *return_name; + { + XIMArg *p; + XStandardColormap *colormap_ret; + int list_ret; + XFontStruct **struct_list; + char **name_list; + int i, len; + int count; + char *tmp; + + for(p = vl; p->name != NULL; p++) { + if(strcmp(p->name, XNArea)==0) { + ic->core.preedit_attr.area.x = ((XRectangle *)p->value)->x; + ic->core.preedit_attr.area.y = ((XRectangle *)p->value)->y; + ic->core.preedit_attr.area.width = ((XRectangle *)p->value)->width; + ic->core.preedit_attr.area.height = ((XRectangle *)p->value)->height; + attr->Area.x = ic->core.preedit_attr.area.x; + attr->Area.y = ic->core.preedit_attr.area.y; + attr->Area.width = ic->core.preedit_attr.area.width; + attr->Area.height = ic->core.preedit_attr.area.height; + XIMP_SET_PREAREAMASK(ic, change_mask); + + } else if(strcmp(p->name, XNAreaNeeded)==0) { + ic->core.preedit_attr.area_needed.width = ((XRectangle *)p->value)->width; + ic->core.preedit_attr.area_needed.height = ((XRectangle *)p->value)->height; + attr->AreaNeeded.width = ic->core.preedit_attr.area_needed.width; + attr->AreaNeeded.height = ic->core.preedit_attr.area_needed.height; + XIMP_SET_PREAREANEEDMASK(ic, change_mask); + + } else if(strcmp(p->name, XNSpotLocation)==0) { + ic->core.preedit_attr.spot_location.x = ((XPoint *)p->value)->x; + ic->core.preedit_attr.spot_location.y = ((XPoint *)p->value)->y; + attr->SpotLocation.x = ic->core.preedit_attr.spot_location.x; + attr->SpotLocation.y = ic->core.preedit_attr.spot_location.y; + XIMP_SET_PRESPOTLMASK(ic, change_mask); + + } else if(strcmp(p->name, XNColormap)==0) { + ic->core.preedit_attr.colormap = (Colormap)p->value; + attr->Colormap = ic->core.preedit_attr.colormap; + XIMP_SET_PRECOLORMAPMASK(ic, change_mask); + + } else if(strcmp(p->name, XNStdColormap)==0) { + if( XGetRGBColormaps(ic->core.im->core.display, + ic->core.focus_window, &colormap_ret, + &count, (Atom)p->value) != 0) { + ic->core.preedit_attr.std_colormap = (Atom)p->value; + attr->StdColormap = ic->core.preedit_attr.std_colormap; + XIMP_SET_PRESTDCOLORMAPMASK(ic, change_mask); + } else { + return_name = p->name; + return(False); + } + + } else if(strcmp(p->name, XNBackground)==0) { + ic->core.preedit_attr.background = (unsigned long)p->value; + attr->Background = ic->core.preedit_attr.background; + XIMP_SET_PREBGMASK(ic, change_mask); + + } else if(strcmp(p->name, XNForeground)==0) { + ic->core.preedit_attr.foreground = (unsigned long)p->value; + attr->Foreground = ic->core.preedit_attr.foreground; + XIMP_SET_PREFGMASK(ic, change_mask); + + } else if(strcmp(p->name, XNBackgroundPixmap)==0) { + ic->core.preedit_attr.background_pixmap = (Pixmap)p->value; + attr->Bg_Pixmap = ic->core.preedit_attr.background_pixmap; + XIMP_SET_PREBGPIXMAPMASK(ic, change_mask); + + } else if(strcmp(p->name, XNFontSet)==0) { + ic->core.preedit_attr.fontset = (XFontSet)p->value; + if(p->value != NULL) { + if(ic->ximp_icpart->preedit_font) + Xfree(ic->ximp_icpart->preedit_font); + list_ret = XFontsOfFontSet(ic->core.preedit_attr.fontset, + &struct_list, &name_list); + for(i = 0, len = 0; i < list_ret; i++) { + len += (strlen(name_list[i]) + sizeof(char)); + } + if( (tmp = Xmalloc(len + list_ret + sizeof(char))) == NULL ) { + return_name = p->name; + return( False ); + } + tmp[0] = NULL; + for(i = 0; i < list_ret; i++) { + strcat(tmp, name_list[i]); + strcat(tmp, ","); + } + tmp[len + i - 1] = NULL; + ic->ximp_icpart->preedit_font = tmp; + XIMP_SET_PREFONTMASK(ic, change_mask); + } else { + return_name = p->name; + return(False); + } + + } else if(strcmp(p->name, XNLineSpace)==0) { + ic->core.preedit_attr.line_space = (long)p->value; + attr->LineSpacing = ic->core.preedit_attr.line_space; + XIMP_SET_PRELINESPMASK(ic, change_mask); + + } else if(strcmp(p->name, XNCursor)==0) { + ic->core.preedit_attr.cursor = (Cursor)p->value; + attr->Cursor = ic->core.preedit_attr.cursor; + XIMP_SET_PRECURSORMASK(ic, change_mask); + + } else if(strcmp(p->name, XNPreeditStartCallback)==0) { + ic->core.preedit_attr.callbacks.start.client_data = + ((XIMCallback *)p->value)->client_data; + ic->core.preedit_attr.callbacks.start.callback = + ((XIMCallback *)p->value)->callback; + ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; + + } else if(strcmp(p->name, XNPreeditDoneCallback)==0) { + ic->core.preedit_attr.callbacks.done.client_data = + ((XIMCallback *)p->value)->client_data; + ic->core.preedit_attr.callbacks.done.callback = + ((XIMCallback *)p->value)->callback; + ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; + + } else if(strcmp(p->name, XNPreeditDrawCallback)==0) { + ic->core.preedit_attr.callbacks.draw.client_data = + ((XIMCallback *)p->value)->client_data; + ic->core.preedit_attr.callbacks.draw.callback = + ((XIMCallback *)p->value)->callback; + ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; + + } else if(strcmp(p->name, XNPreeditCaretCallback)==0) { + ic->core.preedit_attr.callbacks.caret.client_data = + ((XIMCallback *)p->value)->client_data; + ic->core.preedit_attr.callbacks.caret.callback = + ((XIMCallback *)p->value)->callback; + ic->ximp_icpart->value_mask |= XIMP_PRE_CALLBAK; + } + } + return(True); + } + + static Bool + _Ximp_StatusSetAttributes(ic, attr, vl, mode, change_mask, return_name) + Ximp_XIC ic; + Ximp_StatusPropRec4 *attr; + XIMArg *vl; + int mode; + XimpChangeaMask change_mask; + char *return_name; + { + XIMArg *p; + XStandardColormap *colormap_ret; + int list_ret; + XFontStruct **struct_list; + char **name_list; + int i, len; + int count; + char *tmp; + + for(p = vl; p->name != NULL; p++) { + if(strcmp(p->name, XNArea)==0) { + ic->core.status_attr.area.x = ((XRectangle *)p->value)->x; + ic->core.status_attr.area.y = ((XRectangle *)p->value)->y; + ic->core.status_attr.area.width = ((XRectangle *)p->value)->width; + ic->core.status_attr.area.height = ((XRectangle *)p->value)->height; + attr->Area.x = ic->core.status_attr.area.x; + attr->Area.y = ic->core.status_attr.area.y; + attr->Area.width = ic->core.status_attr.area.width; + attr->Area.height = ic->core.status_attr.area.height; + XIMP_SET_STSAREAMASK(ic, change_mask); + + } else if(strcmp(p->name, XNAreaNeeded)==0) { + ic->core.status_attr.area_needed.width = ((XRectangle *)p->value)->width; + ic->core.status_attr.area_needed.height = ((XRectangle *)p->value)->height; + attr->AreaNeeded.width = ic->core.status_attr.area_needed.width; + attr->AreaNeeded.height = ic->core.status_attr.area_needed.height; + XIMP_SET_STSAREANEEDMASK(ic, change_mask); + + } else if(strcmp(p->name, XNColormap)==0) { + ic->core.status_attr.colormap = (Colormap)p->value; + attr->Colormap = ic->core.status_attr.colormap; + XIMP_SET_STSCOLORMAPMASK(ic, change_mask); + + } else if(strcmp(p->name, XNStdColormap)==0) { + if(XGetRGBColormaps(ic->core.im->core.display, + ic->core.focus_window, &colormap_ret, + &count, (Atom)p->value) !=0) { + ic->core.status_attr.std_colormap = (Atom)p->value; + attr->StdColormap = ic->core.status_attr.std_colormap; + XIMP_SET_STSSTDCOLORMAPMASK(ic, change_mask); + } else { + return_name = p->name; + return(False); + } + + } else if(strcmp(p->name, XNBackground)==0) { + ic->core.status_attr.background = (unsigned long)p->value; + attr->Background = ic->core.status_attr.background; + XIMP_SET_STSBGMASK(ic, change_mask); + + } else if(strcmp(p->name, XNForeground)==0) { + ic->core.status_attr.foreground = (unsigned long)p->value; + attr->Foreground = ic->core.status_attr.foreground; + XIMP_SET_STSFGMASK(ic, change_mask); + + } else if(strcmp(p->name, XNBackgroundPixmap)==0) { + ic->core.status_attr.background_pixmap = (Pixmap)p->value; + attr->Bg_Pixmap = ic->core.status_attr.background_pixmap; + XIMP_SET_STSBGPIXMAPMASK(ic, change_mask); + + } else if(strcmp(p->name, XNFontSet)==0) { + ic->core.status_attr.fontset = (XFontSet)p->value; + if (p->value != NULL) { + if(ic->ximp_icpart->status_font) + Xfree(ic->ximp_icpart->status_font); + list_ret = XFontsOfFontSet(ic->core.status_attr.fontset, + &struct_list, &name_list); + for(i = 0, len = 0; i < list_ret; i++) { + len += (strlen(name_list[i]) + sizeof(char)); + } + if((tmp = Xmalloc(len + list_ret + sizeof(char))) == NULL){ + return_name = p->name; + return( False ); + } + tmp[0] = NULL; + for(i = 0; i < list_ret; i++) { + strcat(tmp, name_list[i]); + strcat(tmp, ","); + } + tmp[len + i - 1] = NULL; + ic->ximp_icpart->status_font = tmp; + XIMP_SET_STSFONTMASK(ic, change_mask); + } else { + return_name = p->name; + return(False); + } + + } else if(strcmp(p->name, XNLineSpace)==0) { + ic->core.status_attr.line_space = (long)p->value; + attr->LineSpacing = ic->core.status_attr.line_space; + XIMP_SET_STSLINESPMASK(ic, change_mask); + + } else if(strcmp(p->name, XNCursor)==0) { + ic->core.status_attr.cursor = (Cursor)p->value; + attr->Cursor = ic->core.status_attr.cursor; + XIMP_SET_STSCURSORMASK(ic, change_mask); + + } else if(strcmp(p->name, XNStatusStartCallback)==0) { + ic->core.status_attr.callbacks.start.client_data = + ((XIMCallback *)p->value)->client_data; + ic->core.status_attr.callbacks.start.callback = + ((XIMCallback *)p->value)->callback; + ic->ximp_icpart->value_mask |= XIMP_STS_CALLBAK; + + } else if(strcmp(p->name, XNStatusDoneCallback)==0) { + ic->core.status_attr.callbacks.done.client_data = + ((XIMCallback *)p->value)->client_data; + ic->core.status_attr.callbacks.done.callback = + ((XIMCallback *)p->value)->callback; + ic->ximp_icpart->value_mask |= XIMP_STS_CALLBAK; + + } else if(strcmp(p->name, XNStatusDrawCallback)==0) { + ic->core.status_attr.callbacks.draw.client_data = + ((XIMCallback *)p->value)->client_data; + ic->core.status_attr.callbacks.draw.callback = + ((XIMCallback *)p->value)->callback; + ic->ximp_icpart->value_mask |= XIMP_STS_CALLBAK; + } + } + return(True); + } + + static char * + _Ximp_Local_SetICValues(ic, values) + Ximp_XIC ic; + XIMArg *values; + { + /* Not Yet */ + return(NULL); + } + + static char * + _Ximp_Local_GetICValues(ic, values) + Ximp_XIC ic; + XIMArg *values; + { + XIMArg *p; + char *p_char; + char *return_name = NULL; + int len; + + for(p = values; p->name != NULL; p++) { + if(strcmp(p->name, XNInputStyle) == 0) { + if(ic->ximp_icpart->value_mask & XIMP_INPUT_STYLE) { + *((XIMStyle *)(p->value)) = ic->core.input_style; + } else { + return_name = p->name; + break; + } + } else if(strcmp(p->name, XNClientWindow)==0) { + if(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN) { + *((Window *)(p->value)) = ic->core.client_window; + } else { + return_name = p->name; + break; + } + } else if(strcmp(p->name, XNFocusWindow)==0) { + if(XIMP_CHK_FOCUSWINMASK(ic)) { + *((Window *)(p->value)) = ic->core.focus_window; + } else { + return_name = p->name; + break; + } + } else if(strcmp(p->name, XNResourceName)==0) { + if(ic->core.im->core.res_name != (char *)NULL) { + len = strlen(ic->core.im->core.res_name); + if((p_char = Xmalloc(len+1)) == NULL) { + return_name = p->name; + break; + } + strcpy(p_char, ic->core.im->core.res_name); + *((char **)(p->value)) = p_char; + } else { + return_name = p->name; + break; + } + } else if(strcmp(p->name, XNResourceClass)==0) { + if(ic->core.im->core.res_class != (char *)NULL) { + len = strlen(ic->core.im->core.res_class); + if((p_char = Xmalloc(len+1)) == NULL) { + return_name = p->name; + break; + } + strcpy(p_char, ic->core.im->core.res_class); + *((char **)(p->value)) = p_char; + } else { + return_name = p->name; + break; + } + } else if(strcmp(p->name, XNGeometryCallback)==0) { + if(ic->ximp_icpart->value_mask & XIMP_GEOMETRY_CB) { + *((XIMCallback *)(p->value)) = ic->core.geometry_callback; + } else { + return_name = p->name; + break; + } + } else if(strcmp(p->name, XNFilterEvents)==0) { + *((unsigned long *)(p->value)) = ic->core.filter_events; + } else if(strcmp(p->name, XNPreeditAttributes)==0) { + if( _Ximp_PreGetAttributes(ic, p->value, + &return_name) == False) + break; + } else if(strcmp(p->name, XNStatusAttributes)==0) { + if( _Ximp_StatusGetAttributes(ic, p->value, + &return_name) == False) + break; + } else { + return_name = p->name; + break; + } + } + return(return_name); + } + + static Bool + _Ximp_PreGetAttributes(ic, vl, return_name) + Ximp_XIC ic; + XIMArg *vl; + char **return_name; + { + XIMArg *p; + XRectangle *p_rect; + XPoint *p_point; + XIMCallback *p_callback; + + for(p = vl; p->name != NULL; p++) { + if(strcmp(p->name, XNArea)==0) { + if(XIMP_CHK_PREAREAMASK(ic)) { + if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { + *return_name = p->name; + return(False); + } + p_rect->x = ic->core.preedit_attr.area.x; + p_rect->y = ic->core.preedit_attr.area.y; + p_rect->width = ic->core.preedit_attr.area.width; + p_rect->height = ic->core.preedit_attr.area.height; + } else { + *return_name = p->name; + return(False); + } + *((XRectangle **)(p->value)) = p_rect; + } else if(strcmp(p->name, XNAreaNeeded)==0) { + if(XIMP_CHK_PREAREANEEDMASK(ic)) { + if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { + *return_name = p->name; + return(False); + } + p_rect->x = p_rect->y = 0; + p_rect->width = ic->core.preedit_attr.area_needed.width; + p_rect->height = ic->core.preedit_attr.area_needed.height; + } else { + *return_name = p->name; + return(False); + } + *((XRectangle **)(p->value)) = p_rect; + } else if(strcmp(p->name, XNSpotLocation)==0) { + if(XIMP_CHK_PRESPOTLMASK(ic)) { + if((p_point = (XPoint *)Xmalloc(sizeof(XPoint))) == NULL) { + *return_name = p->name; + return(False); + } + p_point->x = ic->core.preedit_attr.spot_location.x; + p_point->y = ic->core.preedit_attr.spot_location.y; + } else { + *return_name = p->name; + return(False); + } + *((XPoint **)(p->value)) = p_point; + } else if(strcmp(p->name, XNColormap)==0) { + if(XIMP_CHK_PRECOLORMAPMASK(ic)) { + *((Colormap *)(p->value)) = ic->core.preedit_attr.colormap; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNStdColormap)==0) { + if(XIMP_CHK_PRESTDCOLORMAPMASK(ic)) + *((Atom *)(p->value)) = ic->core.preedit_attr.std_colormap; + else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNBackground)==0) { + if(XIMP_CHK_PREBGMASK(ic)) { + *((unsigned long *)(p->value)) = ic->core.preedit_attr.background; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNForeground)==0) { + if(XIMP_CHK_PREFGMASK(ic)) { + *((unsigned long *)(p->value)) = ic->core.preedit_attr.foreground; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNBackgroundPixmap)==0) { + if(XIMP_CHK_PREBGPIXMAPMASK(ic)) { + *((Pixmap *)(p->value)) = ic->core.preedit_attr.background_pixmap; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNFontSet)==0) { + if(XIMP_CHK_PREFONTMASK(ic)) { + *((XFontSet *)(p->value)) = ic->core.preedit_attr.fontset; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNLineSpace)==0) { + if(XIMP_CHK_PRELINESPMASK(ic)) { + *((int *)(p->value)) = ic->core.preedit_attr.line_space; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNCursor)==0) { + if(XIMP_CHK_PRECURSORMASK(ic)) { + *((Cursor *)(p->value)) = ic->core.preedit_attr.cursor; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNPreeditStartCallback)==0) { + if((int)ic->core.preedit_attr.callbacks.start.callback) { + + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.preedit_attr.callbacks.start.client_data; + p_callback->callback = + ic->core.preedit_attr.callbacks.start.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNPreeditDrawCallback)==0) { + if((int)ic->core.preedit_attr.callbacks.draw.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.preedit_attr.callbacks.draw.client_data; + p_callback->callback = + ic->core.preedit_attr.callbacks.draw.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNPreeditDoneCallback)==0) { + if((int)ic->core.preedit_attr.callbacks.done.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.preedit_attr.callbacks.done.client_data; + p_callback->callback = + ic->core.preedit_attr.callbacks.done.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNPreeditCaretCallback)==0) { + if((int)ic->core.preedit_attr.callbacks.caret.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.preedit_attr.callbacks.caret.client_data; + p_callback->callback = + ic->core.preedit_attr.callbacks.caret.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } + } + return(True); + } + + static Bool + _Ximp_StatusGetAttributes(ic, vl, return_name) + Ximp_XIC ic; + XIMArg *vl; + char **return_name; + { + XIMArg *p; + XRectangle *p_rect; + XIMCallback *p_callback; + + for(p = vl; p->name != NULL; p++) { + if(strcmp(p->name, XNArea)==0) { + if(XIMP_CHK_STSAREAMASK(ic)) { + if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { + *return_name = p->name; + return(False); + } + p_rect->x = ic->core.status_attr.area.x; + p_rect->y = ic->core.status_attr.area.y; + p_rect->width = ic->core.status_attr.area.width; + p_rect->height = ic->core.status_attr.area.height; + } else { + *return_name = p->name; + return(False); + } + *((XRectangle **)(p->value)) = p_rect; + } else if(strcmp(p->name, XNAreaNeeded)==0) { + if(XIMP_CHK_STSAREANEEDMASK(ic)) { + if((p_rect = (XRectangle *)Xmalloc(sizeof(XRectangle))) == NULL) { + *return_name = p->name; + return(False); + } + p_rect->x = p_rect->y = 0; + p_rect->width = ic->core.status_attr.area_needed.width; + p_rect->height = ic->core.status_attr.area_needed.height; + } else { + *return_name = p->name; + return(False); + } + *((XRectangle **)(p->value)) = p_rect; + } else if(strcmp(p->name, XNColormap)==0) { + if(XIMP_CHK_STSCOLORMAPMASK(ic)) { + *((Colormap *)(p->value)) = ic->core.status_attr.colormap; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNStdColormap)==0) { + if(XIMP_CHK_STSSTDCOLORMAPMASK(ic)) { + *((Atom *)(p->value)) = ic->core.status_attr.std_colormap; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNBackground)==0) { + if(XIMP_CHK_STSBGMASK(ic)) { + *((unsigned long *)(p->value)) = ic->core.status_attr.background; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNForeground)==0) { + if(XIMP_CHK_STSFGMASK(ic)) { + *((unsigned long *)(p->value)) = ic->core.status_attr.foreground; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNBackgroundPixmap)==0) { + if(XIMP_CHK_STSBGPIXMAPMASK(ic)) { + *((Pixmap *)(p->value)) = ic->core.status_attr.background_pixmap; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNFontSet)==0) { + if(XIMP_CHK_STSFONTMASK(ic)) { + *((XFontSet *)(p->value)) = ic->core.status_attr.fontset; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNLineSpace)==0) { + if(XIMP_CHK_STSLINESPMASK(ic)) { + *((int *)(p->value)) = ic->core.status_attr.line_space; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNCursor)==0) { + if(XIMP_CHK_STSCURSORMASK(ic)) { + *((Cursor *)(p->value)) = ic->core.status_attr.cursor; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNStatusStartCallback)==0) { + if((int)ic->core.status_attr.callbacks.start.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.status_attr.callbacks.start.client_data; + p_callback->callback = + ic->core.status_attr.callbacks.start.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNStatusDrawCallback)==0) { + if((int)ic->core.status_attr.callbacks.draw.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.status_attr.callbacks.draw.client_data; + p_callback->callback = + ic->core.status_attr.callbacks.draw.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } else if(strcmp(p->name, XNStatusDoneCallback)==0) { + if((int)ic->core.status_attr.callbacks.done.callback) { + if((p_callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback))) == NULL) { + *return_name = p->name; + return(False); + } + p_callback->client_data = + ic->core.status_attr.callbacks.done.client_data; + p_callback->callback = + ic->core.status_attr.callbacks.done.callback; + *((XIMCallback **)(p->value)) = p_callback; + } else { + *return_name = p->name; + return(False); + } + } + } + return(True); + } + + static char * + _Ximp_Local_MbReset(ic) + Ximp_XIC ic; + { + ic->ximp_icpart->composed = (DefTree *)NULL; + ic->ximp_icpart->context = ((Ximp_XIM)ic->core.im)->ximp_impart->top; + return(NULL); + } + + static wchar_t * + _Ximp_Local_WcReset(ic) + Ximp_XIC ic; + { + ic->ximp_icpart->composed = (DefTree *)NULL; + ic->ximp_icpart->context = ((Ximp_XIM)ic->core.im)->ximp_impart->top; + return(NULL); + } + + static int + _Ximp_Local_MbLookupString(ic, ev, buffer, bytes, keysym, status) + Ximp_XIC ic; + XKeyEvent *ev; + char * buffer; + int bytes; + KeySym *keysym; + Status *status; + { + int ret; + + if (ev->type != KeyPress) { + if (status) *status = XLookupNone; + return (0); + } + if (ev->keycode == 0) { /* Composed Event */ + ret = strlen(ic->ximp_icpart->composed->mb); + if (ret > bytes) { + if (status) *status = XBufferOverflow; + return (ret); + } + bcopy(ic->ximp_icpart->composed->mb, buffer, ret); + if (keysym) *keysym = NoSymbol; + if (status) *status = XLookupChars; + return (ret); + } else { /* Throughed Event */ + ret = _Ximp_LookupMBText(ic, ev, buffer, bytes, keysym, NULL); + if(ret > 0) { + if(keysym && *keysym != NoSymbol) { + if(status) *status = XLookupBoth; + } else { + if(status) *status = XLookupChars; + } + } else { + if(keysym && *keysym != NoSymbol) { + if(status) *status = XLookupKeySym; + } else { + if(status) *status = XLookupNone; + } + } + } + return (ret); + } + + static int + _Ximp_Local_WcLookupString(ic, ev, buffer, wlen, keysym, status) + Ximp_XIC ic; + XKeyEvent *ev; + wchar_t * buffer; + int wlen; + KeySym *keysym; + Status *status; + { + int ret; + + if (ev->type != KeyPress) { + if (status) *status = XLookupNone; + return (0); + } + if (ev->keycode == 0) { /* Composed Event */ + ret = _Xwcslen(ic->ximp_icpart->composed->wc); + if (ret > wlen) { + if (status) *status = XBufferOverflow; + return (ret); + } + bcopy(ic->ximp_icpart->composed->wc, buffer, ret * sizeof(wchar_t)); + if (keysym) *keysym = NoSymbol; + if (status) *status = XLookupChars; + return (ret); + } else { /* Throughed Event */ + ret = _Ximp_LookupWCText(ic, ev, buffer, wlen, keysym, NULL); + if(ret > 0) { + if(keysym && *keysym != NoSymbol) { + if(status) *status = XLookupBoth; + } else { + if(status) *status = XLookupChars; + } + } else { + if(keysym && *keysym != NoSymbol) { + if(status) *status = XLookupKeySym; + } else { + if(status) *status = XLookupNone; + } + } + } + return (ret); + } *** /dev/null Tue Mar 9 09:25:11 1993 --- mit/lib/X/Ximp/XimpParser.c Tue Mar 9 09:25:18 1993 *************** *** 0 **** --- 1,493 ---- + /* $XConsortium: XimpParser.c,v 1.1 92/10/19 19:25:59 rws Exp $ */ + /****************************************************************** + + Copyright 1992 by Oki Technosystems Laboratory, Inc. + Copyright 1992 by Fuji Xerox Co., Ltd. + + Permission to use, copy, modify, distribute, and sell this software + and its documentation for any purpose is hereby granted without fee, + provided that the above copyright notice appear in all copies and + that both that copyright notice and this permission notice appear + in supporting documentation, and that the name of Oki Technosystems + Laboratory and Fuji Xerox not be used in advertising or publicity + pertaining to distribution of the software without specific, written + prior permission. + Oki Technosystems Laboratory and Fuji Xerox make no representations + about the suitability of this software for any purpose. It is provided + "as is" without express or implied warranty. + + OKI TECHNOSYSTEMS LABORATORY AND FUJI XEROX DISCLAIM ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL OKI TECHNOSYSTEMS + LABORATORY AND FUJI XEROX BE LIABLE FOR ANY SPECIAL, INDIRECT OR + CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE + OR PERFORMANCE OF THIS SOFTWARE. + + Author: Yasuhiro Kawai Oki Technosystems Laboratory + Author: Kazunori Nishihara Fuji Xerox + + ******************************************************************/ + + #include + #include + #include "Xlibint.h" + #include "Xlcint.h" + + #include "Ximplc.h" + + /* + * Parsing File Format: + * + * FILE ::= { [PRODUCTION] [COMMENT] "\n"} + * PRODUCTION ::= LHS ":" RHS [ COMMENT ] + * COMMENT ::= "#" {} + * LHS ::= EVENT { EVENT } + * EVENT ::= [MODIFIER_LIST] "<" keysym ">" + * MODIFIER_LIST ::= ("!" {MODIFIER} ) | "None" + * MODIFIER ::= ["~"] modifier_name + * RHS ::= ( STRING | keysym | STRING keysym ) + * STRING ::= '"' { CHAR } '"' + * CHAR ::= GRAPHIC_CHAR | ESCAPED_CHAR + * GRAPHIC_CHAR ::= locale (codeset) dependent code + * ESCAPED_CHAR ::= ('\\' | '\"' | OCTAL | HEX ) + * OCTAL ::= '\' OCTAL_CHAR [OCTAL_CHAR [OCTAL_CHAR]] + * OCTAL_CHAR ::= (0|1|2|3|4|5|6|7) + * HEX ::= '\' (x|X) HEX_CHAR [HEX_CHAR]] + * HEX_CHAR ::= (0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|a|b|c|d|e|f) + * + */ + + static int lastch = NULL; + + static int + nextch(fp) + FILE *fp; + { + int c; + + if (lastch != NULL) { + c = lastch; + lastch = NULL; + } else { + c = getc(fp); + if (c == '\\') { + c = getc(fp); + if (c == '\n') { + c = getc(fp); + } else { + ungetc(c, fp); + c = '\\'; + } + } + } + return(c); + } + + static void + putbackch(c) + int c; + { + lastch = c; + } + + #define ENDOFFILE 0 + #define ENDOFLINE 1 + #define COLON 2 + #define LESS 3 + #define GREATER 4 + #define EXCLAM 5 + #define TILDE 6 + #define STRING 7 + #define KEY 8 + #define ERROR 9 + + #define MAXSTRLEN 100 + + #ifndef isalnum + #define isalnum(c) \ + (('0' <= (c) && (c) <= '9') || \ + ('A' <= (c) && (c) <= 'Z') || \ + ('a' <= (c) && (c) <= 'z')) + #endif + + static char tokenbuf[MAXSTRLEN]; + + static int + nexttoken(fp) + FILE *fp; + { + int c; + int token; + char *p; + int i, j; + + while ((c = nextch(fp)) == ' ' || c == '\t') { + } + switch (c) { + case EOF: + token = ENDOFFILE; + break; + case '\n': + token = ENDOFLINE; + break; + case '<': + token = LESS; + break; + case '>': + token = GREATER; + break; + case ':': + token = COLON; + break; + case '!': + token = EXCLAM; + break; + case '~': + token = TILDE; + break; + case '"': + p = tokenbuf; + while ((c = nextch(fp)) != '"') { + if (c == '\n' || c == EOF) { + putbackch(c); + token = ERROR; + goto string_error; + } else if (c == '\\') { + c = nextch(fp); + switch (c) { + case '\\': + case '"': + *p++ = c; + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + i = c - '0'; + c = nextch(fp); + for (j = 0; j < 2 && c >= '0' && c <= '7'; j++) { + i <<= 3; + i += c - '0'; + c = nextch(fp); + } + putbackch(c); + *p++ = (char)i; + break; + case 'X': + case 'x': + i = 0; + c = nextch(fp); + #define ishexch(c) (((c) >= '0' && (c) <= '9') || \ + ((c) >= 'A' && (c) <= 'F') || \ + ((c) >= 'a' && (c) <= 'f')) + for (j = 0; j < 2 && ishexch(c); j++) { + i <<= 4; + if (c >= '0' && c <= '9') { + i += c - '0'; + } else if (c >= 'A' && c <= 'F') { + i += c - 'A' + 10; + } else { + i += c - 'a' + 10; + } + c = nextch(fp); + } + if (j == 0) { + token = ERROR; + goto string_error; + } + putbackch(c); + #undef ishexch + break; + case '\n': + case EOF: + putbackch(c); + token = ERROR; + goto string_error; + break; + default: + *p++ = c; + break; + } + } else { + *p++ = c; + } + } + *p = '\0'; + token = STRING; + break; + case '#': + while ((c = nextch(fp)) != '\n' && c != EOF) { + } + if (c == '\n') { + token = ENDOFLINE; + } else { + token = ENDOFFILE; + } + break; + default: + if (isalnum(c) || c == '_' || c == '-') { + p = tokenbuf; + *p++ = c; + c = nextch(fp); + while (isalnum(c) || c == '_' || c == '-') { + *p++ = c; + c = nextch(fp); + } + *p = '\0'; + putbackch(c); + token = KEY; + } else { + token = ERROR; + } + break; + } + string_error: + return(token); + } + + static long + modmask(name) + char *name; + { + long mask; + + struct _modtbl { + char *name; + long mask; + }; + struct _modtbl *p; + + static struct _modtbl tbl[] = { + { "Ctrl", ControlMask }, + { "Lock", LockMask }, + { "Caps", LockMask }, + { "Shift", ShiftMask }, + { "Alt", Mod1Mask }, + { "Meta", Mod1Mask }, + { NULL, 0 }}; + + p = tbl; + mask = 0; + for (p = tbl; p->name != NULL; p++) { + if (strcmp(name, p->name) == 0) { + mask = p->mask; + break; + } + } + return(mask); + } + + #define AllMask (ShiftMask | LockMask | ControlMask | Mod1Mask) + #define LOCAL_WC_BUFSIZE 128 + #define SEQUENCE_MAX 10 + + static int + parseline(fp, top) + FILE *fp; + DefTree **top; + { + int token; + unsigned modifier_mask; + unsigned modifier; + unsigned tmp; + KeySym keysym; + DefTree *p; + Bool exclam, tilde; + KeySym rhs_keysym; + char *rhs_string_mb; + int l; + wchar_t local_wc_buf[LOCAL_WC_BUFSIZE], *rhs_string_wc; + + struct DefBuffer { + unsigned modifier_mask; + unsigned modifier; + KeySym keysym; + }; + + struct DefBuffer buf[SEQUENCE_MAX]; + int i, n; + + do { + token = nexttoken(fp); + } while (token == ENDOFLINE); + + if (token == ENDOFFILE) { + return(-1); + } + + n = 0; + do { + if ((token == KEY) && (strcmp("None", tokenbuf) == 0)) { + modifier = 0; + modifier_mask = AllMask; + token = nexttoken(fp); + } else { + modifier_mask = modifier = 0; + exclam = False; + if (token == EXCLAM) { + exclam = True; + token = nexttoken(fp); + } + while (token == TILDE || token == KEY) { + tilde = False; + if (token == TILDE) { + token = nexttoken(fp); + tilde = True; + if (token != KEY) + goto error; + } + token = nexttoken(fp); + tmp = modmask(tokenbuf); + if (!tmp) { + goto error; + } + modifier_mask |= tmp; + if (tilde) { + modifier &= ~tmp; + } else { + modifier |= tmp; + } + } + if (exclam) { + modifier_mask = AllMask; + } + } + + if (token != LESS) { + goto error; + } + + token = nexttoken(fp); + if (token != KEY) { + goto error; + } + + token = nexttoken(fp); + if (token != GREATER) { + goto error; + } + + keysym = XStringToKeysym(tokenbuf); + if (keysym == NoSymbol) { + goto error; + } + + buf[n].keysym = keysym; + buf[n].modifier = modifier; + buf[n].modifier_mask = modifier_mask; + n++; + if( n >= SEQUENCE_MAX ) + goto error; + token = nexttoken(fp); + } while (token != COLON); + + token = nexttoken(fp); + if (token == STRING) { + if( (rhs_string_mb = Xmalloc(strlen(tokenbuf) + 1)) == NULL ) + goto error; + strcpy(rhs_string_mb, tokenbuf); + token = nexttoken(fp); + if (token == KEY) { + rhs_keysym = XStringToKeysym(tokenbuf); + if (rhs_keysym == NoSymbol) { + Xfree(rhs_string_mb); + goto error; + } + token = nexttoken(fp); + } + if (token != ENDOFLINE && token != ENDOFFILE) { + Xfree(rhs_string_mb); + goto error; + } + } else if (token == KEY) { + rhs_keysym = XStringToKeysym(tokenbuf); + if (rhs_keysym == NoSymbol) { + goto error; + } + token = nexttoken(fp); + if (token != ENDOFLINE && token != ENDOFFILE) { + goto error; + } + if( (rhs_string_mb = Xmalloc(1)) == NULL ) { + Xfree( rhs_string_mb ); + goto error; + } + rhs_string_mb[0] = '\0'; + } else { + goto error; + } + + l = _Xmbstowcs(local_wc_buf, rhs_string_mb, LOCAL_WC_BUFSIZE - 1); + if (l == LOCAL_WC_BUFSIZE - 1) { + local_wc_buf[l] = (wchar_t)'\0'; + } + if( (rhs_string_wc = (wchar_t *)Xmalloc((l + 1) * sizeof(wchar_t))) == NULL ) { + Xfree( rhs_string_mb ); + return( 0 ); + } + bcopy( local_wc_buf, rhs_string_wc, (l + 1) * sizeof(wchar_t) ); + + for (i = 0; i < n; i++) { + for (p = *top; p; p = p->next) { + if (buf[i].keysym == p->keysym && + buf[i].modifier == p->modifier && + buf[i].modifier_mask == p->modifier_mask) { + break; + } + } + if (p) { + top = &p->succession; + } else { + if( (p = (DefTree*)Xmalloc(sizeof(DefTree))) == NULL ) { + Xfree( rhs_string_mb ); + goto error; + } + p->keysym = buf[i].keysym; + p->modifier = buf[i].modifier; + p->modifier_mask = buf[i].modifier_mask; + p->succession = NULL; + p->next = *top; + p->mb = NULL; + p->wc = NULL; + #ifdef notdef + p->keysym_return = NoSymbol; + #endif + *top = p; + top = &p->succession; + } + } + + if( p->mb != NULL ) + Xfree( p->mb ); + p->mb = rhs_string_mb; + if( p->wc != NULL ) + Xfree( p->wc ); + p->wc = rhs_string_wc; + #ifdef notdef + p->keysym_return = rhs_keysym; + #endif + return(n); + error: + while (token != ENDOFLINE && token != ENDOFFILE) { + token = nexttoken(fp); + } + return(0); + } + + int + Ximp_ParseStringFile(fp, ptop) + FILE *fp; + DefTree **ptop; + { + int max_ev_seq = 0, i; + while ((i = parseline(fp, ptop)) >= 0) { + if (i > max_ev_seq) max_ev_seq = i; + } + return (max_ev_seq); + } *** /tmp/d04262 Tue Mar 9 09:26:25 1993 --- mit/lib/nls/Ximp/Imakefile Tue Mar 9 09:26:22 1993 *************** *** 1,9 **** #define IHaveSubdirs - #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' INSTALLFLAGS = $(INSTDATFLAGS) ! SUBDIRS = C ja_JP.EUC ja_JP.SJIS ! MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) --- 1,25 ---- + XCOMM $XConsortium: Imakefile,v 1.3 93/02/24 17:49:52 rws Exp $ + #define IHaveSubdirs + #if SystemV4 + EUC32 = YES + #else + EUC32 = NO + #endif + INSTALLFLAGS = $(INSTDATFLAGS) ! SUBDIRS = C iso8859 ja_JP.EUC ja_JP.JIS ja_JP.SJIS ko zh zh_TW ! #ifdef XlibI18nPath ! XLIBI18N_PATH = XlibI18nPath ! #else ! XLIBI18N_PATH = $(LIBDIR) ! #endif ! LOCALE_ALIAS = locale.alias ! ! NamedTargetSubdirs(all,$(SUBDIRS),"making" all,EUC32=$(EUC32),all) DependSubdirs($(SUBDIRS)) + + InstallMultiple($(LOCALE_ALIAS),$(XLIBI18N_PATH)) *** /dev/null Tue Mar 9 09:26:27 1993 --- mit/lib/nls/Ximp/locale.alias Tue Mar 9 09:26:33 1993 *************** *** 0 **** --- 1,75 ---- + # $XConsortium: locale.alias,v 1.2 93/02/24 17:54:23 rws Exp $ + + da da.ISO8859-1 + da_DK da.ISO8859-1 + + de de.ISO8859-1 + de_DE de.ISO8859-1 + de_AT de.ISO8859-1 + de_CH de.ISO8859-1 + + el el.ISO8859-7 + el_GR el.ISO8859-7 + + en en.ISO8859-1 + en_GB en.ISO8859-1 + en_AU en.ISO8859-1 + en_CA en.ISO8859-1 + en_US en.ISO8859-1 + + es es.ISO8859-1 + es_ES es.ISO8859-1 + + fi fi.ISO8859-1 + fi_FI fi.ISO8859-1 + + fr fr.ISO8859-1 + fr_FR fr.ISO8859-1 + fr_BE fr.ISO8859-1 + fr_CA fr.ISO8859-1 + fr_CH fr.ISO8859-1 + + is is.ISO8859-1 + is_IS is.ISO8859-1 + + it it.ISO8859-1 + it_IT it.ISO8859-1 + it_CH it.ISO8859-1 + + ja ja_JP.EUC + ja_JP ja_JP.EUC + japan ja_JP.EUC + japanese ja_JP.EUC + ja_JP.SJIS ja_JP.SJIS + + ko ko.EUC + ko_KR ko.EUC + + nl nl.ISO8859-1 + nl_NL nl.ISO8859-1 + nl_BE nl.ISO8859-1 + + no no.ISO8859-1 + no_NO no.ISO8859-1 + + pl pl.ISO8859-2 + pl_PL pl.ISO8859-2 + + pt pt.ISO8859-1 + pt_PT pt.ISO8859-1 + + ru ru.ISO8859-5 + ru_SU ru.ISO8859-5 + + sh sh.ISO8859-2 + sh_YU sh.ISO8859-2 + + sk sk.ISO8859-2 + + sv sv.ISO8859-1 + sv_SE sv.ISO8859-1 + + tr tr.ISO8859-3 + + zh zh.EUC + zh_TW zh_TW.EUC *** /tmp/d04314 Tue Mar 9 09:27:58 1993 --- mit/lib/nls/Ximp/C/Imakefile Tue Mar 9 09:27:54 1993 *************** *** 1,9 **** INSTALLFLAGS = $(INSTDATFLAGS) LCFILES = Codeset ! all:: depend:: ! InstallMultiple($(LCFILES),$(LIBDIR)/C) --- 1,21 ---- + XCOMM $XConsortium: Imakefile,v 1.3 93/02/24 17:56:45 rws Exp $ + + EUC32 = 0 INSTALLFLAGS = $(INSTDATFLAGS) + #ifdef XlibI18nPath + XLIBI18N_PATH = XlibI18nPath + #else + XLIBI18N_PATH = $(LIBDIR) + #endif LCFILES = Codeset ! AllTarget($(LCFILES)) ! CppFileTarget($(LCFILES), $(LCFILES).cpp, -DEUC32=$(EUC32), NullParameter) + clean:: + $(RM) $(LCFILES) + depend:: ! InstallMultiple($(LCFILES),$(XLIBI18N_PATH)/C) *** /dev/null Tue Mar 9 09:28:00 1993 --- mit/lib/nls/Ximp/C/Codeset.cpp Tue Mar 9 09:28:07 1993 *************** *** 0 **** --- 1,26 ---- + /* $XConsortium: Codeset.cpp,v 1.2 93/02/24 17:57:45 rws Exp $ */ + + NAME C + + MB_CUR_MAX 1 + + STATE_DEPEND_ENCODING FALSE + + #if EUC32 + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + #else + WC_ENCODING_MASK 0x00008080 + WC_SHIFT_BITS 8 + #endif + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-1 GL + FONT + ISO8859-1 GL + *** /dev/null Tue Mar 9 09:28:13 1993 --- mit/lib/nls/Ximp/iso8859/Codeset1.cpp Tue Mar 9 09:28:21 1993 *************** *** 0 **** --- 1,39 ---- + /* $XConsortium: Codeset1.cpp,v 1.3 93/02/24 18:02:29 rws Exp $ */ + + NAME ISO8859-1 + + MB_CUR_MAX 1 + + STATE_DEPEND_ENCODING FALSE + + #if EUC32 + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + #else + WC_ENCODING_MASK 0x00008080 + WC_SHIFT_BITS 8 + #endif + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-1 GL + FONT + ISO8859-1 GL + + CODESET1 + GR + INITIAL_STATE_GR + LENGTH 1 + #if EUC32 + WC_ENCODING 0x30000000 + #else + WC_ENCODING 0x00008080 + #endif + ENCODING + ISO8859-1 GR + FONT + ISO8859-1 GR *** /dev/null Tue Mar 9 09:28:26 1993 --- mit/lib/nls/Ximp/iso8859/Codeset2.cpp Tue Mar 9 09:28:33 1993 *************** *** 0 **** --- 1,41 ---- + /* $XConsortium: Codeset2.cpp,v 1.2 93/02/24 18:02:37 rws Exp $ */ + + NAME ISO8859-2 + + MB_CUR_MAX 1 + + STATE_DEPEND_ENCODING FALSE + + #if EUC32 + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + #else + WC_ENCODING_MASK 0x00008080 + WC_SHIFT_BITS 8 + #endif + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-2 GL + ISO8859-1 GL + FONT + ISO8859-2 GL + ISO8859-1 GL + + CODESET1 + GR + INITIAL_STATE_GR + LENGTH 1 + #if EUC32 + WC_ENCODING 0x30000000 + #else + WC_ENCODING 0x00008080 + #endif + ENCODING + ISO8859-2 GR + FONT + ISO8859-2 GR *** /dev/null Tue Mar 9 09:28:38 1993 --- mit/lib/nls/Ximp/iso8859/Codeset3.cpp Tue Mar 9 09:28:46 1993 *************** *** 0 **** --- 1,41 ---- + /* $XConsortium: Codeset3.cpp,v 1.2 93/02/24 18:02:42 rws Exp $ */ + + NAME ISO8859-3 + + MB_CUR_MAX 1 + + STATE_DEPEND_ENCODING FALSE + + #if EUC32 + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + #else + WC_ENCODING_MASK 0x00008080 + WC_SHIFT_BITS 8 + #endif + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-3 GL + ISO8859-1 GL + FONT + ISO8859-3 GL + ISO8859-1 GL + + CODESET1 + GR + INITIAL_STATE_GR + LENGTH 1 + #if EUC32 + WC_ENCODING 0x30000000 + #else + WC_ENCODING 0x00008080 + #endif + ENCODING + ISO8859-3 GR + FONT + ISO8859-3 GR *** /dev/null Tue Mar 9 09:28:53 1993 --- mit/lib/nls/Ximp/iso8859/Codeset5.cpp Tue Mar 9 09:29:00 1993 *************** *** 0 **** --- 1,41 ---- + /* $XConsortium: Codeset5.cpp,v 1.2 93/02/24 18:02:46 rws Exp $ */ + + NAME ISO8859-5 + + MB_CUR_MAX 1 + + STATE_DEPEND_ENCODING FALSE + + #if EUC32 + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + #else + WC_ENCODING_MASK 0x00008080 + WC_SHIFT_BITS 8 + #endif + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-5 GL + ISO8859-1 GL + FONT + ISO8859-5 GL + ISO8859-1 GL + + CODESET1 + GR + INITIAL_STATE_GR + LENGTH 1 + #if EUC32 + WC_ENCODING 0x30000000 + #else + WC_ENCODING 0x00008080 + #endif + ENCODING + ISO8859-5 GR + FONT + ISO8859-5 GR *** /dev/null Tue Mar 9 09:29:05 1993 --- mit/lib/nls/Ximp/iso8859/Codeset7.cpp Tue Mar 9 09:29:12 1993 *************** *** 0 **** --- 1,41 ---- + /* $XConsortium: Codeset7.cpp,v 1.2 93/02/24 18:02:50 rws Exp $ */ + + NAME ISO8859-7 + + MB_CUR_MAX 1 + + STATE_DEPEND_ENCODING FALSE + + #if EUC32 + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + #else + WC_ENCODING_MASK 0x00008080 + WC_SHIFT_BITS 8 + #endif + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-7 GL + ISO8859-1 GL + FONT + ISO8859-7 GL + ISO8859-1 GL + + CODESET1 + GR + INITIAL_STATE_GR + LENGTH 1 + #if EUC32 + WC_ENCODING 0x30000000 + #else + WC_ENCODING 0x00008080 + #endif + ENCODING + ISO8859-7 GR + FONT + ISO8859-7 GR *** /dev/null Tue Mar 9 09:29:16 1993 --- mit/lib/nls/Ximp/iso8859/Compose Tue Mar 9 09:29:23 1993 *************** *** 0 **** --- 1,354 ---- + # $XConsortium: Compose,v 1.2 93/02/24 18:02:53 rws Exp $ + # + # ISO 8859-1 (Latin1) Compose Sequence + # + # Sequence Definition + # + # Means + # Special Character + : "#" # Number Sign + : "'" # Apostrophe + : "@" # Commercial At + : "[" # Opening Bracket + : "\\" # Backslash + : "\\" # Backslash + : "]" # Closing Bracket + : "^" # Circumflex Accent + : "^" # Circumflex Accent + : "`" # Grave Accent + : "{" # Opening Brace + : "|" # Vertical Line + : "|" # Vertical Line + : "|" # Vertical Line + : "}" # Closing Brace + : "~" # Tilde + : "~" # Tilde + : "\241" # Inverted ! + : "\242" # Cent Sign + : "\242" # Cent Sign + : "\242" # Cent Sign + : "\242" # Cent Sign + : "\243" # Pound Sign + : "\243" # Pound Sign + : "\243" # Pound Sign + : "\243" # Pound Sign + : "\245" # Yen Sign + : "\245" # Yen Sign + : "\245" # Yen Sign + : "\245" # Yen Sign + : "\247" # Section Sign + : "\247" # Section Sign + : "\247" # Section Sign + : "\247" # Section Sign + <0> : "\247" # Section Sign + <0> : "\247" # Section Sign + : "\244" # Currency Sign + : "\244" # Currency Sign + : "\244" # Currency Sign + : "\244" # Currency Sign + <0> : "\244" # Currency Sign + <0> : "\244" # Currency Sign + : "\251" # Copyright + : "\251" # Copyright + : "\251" # Copyright + : "\251" # Copyright + <0> : "\251" # Copyright + <0> : "\251" # Copyright + : "\252" # Feminine Ordinal Indicator + : "\252" # Feminine Ordinal Indicator + : "\272" # Masculine Ordinal Indicator + : "\272" # Masculine Ordinal Indicator + : "\253" # Angle Quotation Mark Left + : "\273" # Angle Quotation Mark Right + <0> : "\260" # Degree Sign + <0> : "\260" # Degree Sign + : "\261" # Plus/Minus Sign + : "\265" # Micro Sign + : "\265" # Micro Sign + <1> : "\271" # Superscript 1 + <1> : "\271" # Superscript 1 + <1> : "\271" # Superscript 1 + <2> : "\262" # Superscript 2 + <2> : "\262" # Superscript 2 + <2> : "\262" # Superscript 2 + <3> : "\263" # Superscript 3 + <3> : "\263" # Superscript 3 + <3> : "\263" # Superscript 3 +

: "\266" # Paragraph Sign +

: "\266" # Paragraph Sign + : "\267" # Middle Dot + : "\267" # Middle Dot + <1> <4> : "\274" # Fraction One Quarter + <1> <2> : "\275" # Fraction One Half + <3> <4> : "\276" # Fraction Three Quarter + : "\277" # Inverted ? + : "\240" # No Break Space + : "\246" # Broken Bar Vertical + : "\246" # Broken Bar Vertical + : "\246" # Broken Bar Vertical + : "\246" # Broken Bar Vertical + : "\254" # Logocal Not + : "\255" # Soft Syllable Hyphen + : "\256" # Registered Trademark + : "\257" # Macron + : "\257" # Macron + : "\257" # Macron + : "\367" # Division Sign + : "\327" # Multiplication Sign + : "\264" # Acute Accent + : "\270" # Cedilla + : "\250" # Diaeresis + # Accented Alphabet + : "\300" # A Grave + : "\301" # A Acute + : "\302" # A Circumflex + : "\302" # A Circumflex + : "\303" # A Tilde + : "\303" # A Tilde + : "\304" # A Umlaut + : "\305" # A Ring + : "\306" # A E Diphthong + : "\340" # a Grave + : "\341" # a Acute + : "\342" # a Circumflex + : "\342" # a Circumflex + : "\343" # a Tilde + : "\343" # a Tilde + : "\344" # a Umlaut + : "\345" # a Ring + : "\346" # a e Diphthong + : "\307" # C Cedilla + : "\347" # c Cedilla + : "\320" # Capital Icelandic Eth + : "\360" # Small Icelandic Eth + : "\310" # E Grave + : "\311" # E Acute + : "\312" # E Circumflex + : "\312" # E Circumflex + : "\313" # E Umlaut + : "\350" # e Grave + : "\351" # e Acute + : "\352" # e Circumflex + : "\352" # e Circumflex + : "\353" # e Umlaut + : "\314" # I Grave + : "\315" # I Acute + : "\316" # I Circumflex + : "\316" # I Circumflex + : "\317" # I Umlaut + : "\354" # i Grave + : "\355" # i Acute + : "\356" # i Circumflex + : "\356" # i Circumflex + : "\357" # i Umlaut + : "\321" # N Tilde + : "\321" # N Tilde + : "\361" # n Tilde + : "\361" # n Tilde + : "\322" # O Grave + : "\323" # O Acute + : "\324" # O Circumflex + : "\324" # O Circumflex + : "\325" # O Tilde + : "\325" # O Tilde + : "\326" # O Umlaut + : "\330" # O Slash + : "\362" # o Grave + : "\363" # o Acute + : "\364" # o Circumflex + : "\364" # o Circumflex + : "\365" # o Tilde + : "\365" # o Tilde + : "\366" # o Umlaut + : "\370" # o Slash + : "\331" # U Grave + : "\332" # U Acute + : "\333" # U Circumflex + : "\333" # U Circumflex + : "\334" # U Umlaut + : "\371" # u Grave + : "\372" # u Acute + : "\373" # u Circumflex + : "\373" # u Circumflex + : "\374" # u Umlaut + : "\337" # German Small Sharp s + : "\336" # Capital Icelandic Thor + : "\376" # Small Icelandic Thor + : "\335" # Y Acute + : "\375" # y Acute + : "\377" # y Umlaut + # + # Ctrl Means + # Special Character + Ctrl : "#" # Number Sign + Ctrl : "'" # Apostrophe + Ctrl : "@" # Commercial At + Ctrl : "[" # Opening Bracket + Ctrl : "\\" # Backslash + Ctrl : "\\" # Backslash + Ctrl : "]" # Closing Bracket + Ctrl : "^" # Circumflex Accent + Ctrl : "^" # Circumflex Accent + Ctrl : "`" # Grave Accent + Ctrl : "{" # Opening Brace + Ctrl : "|" # Vertical Line + Ctrl : "|" # Vertical Line + Ctrl : "|" # Vertical Line + Ctrl : "}" # Closing Brace + Ctrl : "~" # Tilde + Ctrl : "~" # Tilde + Ctrl : "\241" # Inverted ! + Ctrl : "\242" # Cent Sign + Ctrl : "\242" # Cent Sign + Ctrl : "\242" # Cent Sign + Ctrl : "\242" # Cent Sign + Ctrl : "\243" # Pound Sign + Ctrl : "\243" # Pound Sign + Ctrl : "\243" # Pound Sign + Ctrl : "\243" # Pound Sign + Ctrl : "\245" # Yen Sign + Ctrl : "\245" # Yen Sign + Ctrl : "\245" # Yen Sign + Ctrl : "\245" # Yen Sign + Ctrl : "\247" # Section Sign + Ctrl : "\247" # Section Sign + Ctrl : "\247" # Section Sign + Ctrl : "\247" # Section Sign + Ctrl <0> : "\247" # Section Sign + Ctrl <0> : "\247" # Section Sign + Ctrl : "\244" # Currency Sign + Ctrl : "\244" # Currency Sign + Ctrl : "\244" # Currency Sign + Ctrl : "\244" # Currency Sign + Ctrl <0> : "\244" # Currency Sign + Ctrl <0> : "\244" # Currency Sign + Ctrl : "\251" # Copyright + Ctrl : "\251" # Copyright + Ctrl : "\251" # Copyright + Ctrl : "\251" # Copyright + Ctrl <0> : "\251" # Copyright + Ctrl <0> : "\251" # Copyright + Ctrl : "\252" # Feminine Ordinal Indicator + Ctrl : "\252" # Feminine Ordinal Indicator + Ctrl : "\272" # Masculine Ordinal Indicator + Ctrl : "\272" # Masculine Ordinal Indicator + Ctrl : "\253" # Angle Quotation Mark Left + Ctrl : "\273" # Angle Quotation Mark Right + Ctrl <0> : "\260" # Degree Sign + Ctrl <0> : "\260" # Degree Sign + Ctrl : "\261" # Plus/Minus Sign + Ctrl : "\265" # Micro Sign + Ctrl : "\265" # Micro Sign + Ctrl <1> : "\271" # Superscript 1 + Ctrl <1> : "\271" # Superscript 1 + Ctrl <1> : "\271" # Superscript 1 + Ctrl <2> : "\262" # Superscript 2 + Ctrl <2> : "\262" # Superscript 2 + Ctrl <2> : "\262" # Superscript 2 + Ctrl <3> : "\263" # Superscript 3 + Ctrl <3> : "\263" # Superscript 3 + Ctrl <3> : "\263" # Superscript 3 + Ctrl

: "\266" # Paragraph Sign + Ctrl

: "\266" # Paragraph Sign + Ctrl : "\267" # Middle Dot + Ctrl : "\267" # Middle Dot + Ctrl <1> <4> : "\274" # Fraction One Quarter + Ctrl <1> <2> : "\275" # Fraction One Half + Ctrl <3> <4> : "\276" # Fraction Three Quarter + Ctrl : "\277" # Inverted ? + Ctrl : "\240" # No Break Space + Ctrl : "\246" # Broken Bar Vertical + Ctrl : "\246" # Broken Bar Vertical + Ctrl : "\246" # Broken Bar Vertical + Ctrl : "\246" # Broken Bar Vertical + Ctrl : "\254" # Logocal Not + Ctrl : "\255" # Soft Syllable Hyphen + Ctrl : "\256" # Registered Trademark + Ctrl : "\257" # Macron + Ctrl : "\257" # Macron + Ctrl : "\257" # Macron + Ctrl : "\367" # Division Sign + Ctrl : "\327" # Multiplication Sign + Ctrl : "\264" # Acute Accent + Ctrl : "\270" # Cedilla + Ctrl : "\250" # Diaeresis + + Ctrl : "\300" # A Grave + Ctrl : "\301" # A Acute + Ctrl : "\302" # A Circumflex + Ctrl : "\302" # A Circumflex + Ctrl : "\303" # A Tilde + Ctrl : "\303" # A Tilde + Ctrl : "\304" # A Umlaut + Ctrl : "\305" # A Ring + Ctrl : "\306" # A E Diphthong + Ctrl : "\340" # a Grave + Ctrl : "\341" # a Acute + Ctrl : "\342" # a Circumflex + Ctrl : "\342" # a Circumflex + Ctrl : "\343" # a Tilde + Ctrl : "\343" # a Tilde + Ctrl : "\344" # a Umlaut + Ctrl : "\345" # a Ring + Ctrl : "\346" # a e Diphthong + Ctrl : "\307" # C Cedilla + Ctrl : "\347" # c Cedilla + Ctrl : "\320" # Capital Icelandic Eth + Ctrl : "\360" # Small Icelandic Eth + Ctrl : "\310" # E Grave + Ctrl : "\311" # E Acute + Ctrl : "\312" # E Circumflex + Ctrl : "\312" # E Circumflex + Ctrl : "\313" # E Umlaut + Ctrl : "\350" # e Grave + Ctrl : "\351" # e Acute + Ctrl : "\352" # e Circumflex + Ctrl : "\352" # e Circumflex + Ctrl : "\353" # e Umlaut + Ctrl : "\314" # I Grave + Ctrl : "\315" # I Acute + Ctrl : "\316" # I Circumflex + Ctrl : "\316" # I Circumflex + Ctrl : "\317" # I Umlaut + Ctrl : "\354" # i Grave + Ctrl : "\355" # i Acute + Ctrl : "\356" # i Circumflex + Ctrl : "\356" # i Circumflex + Ctrl : "\357" # i Umlaut + Ctrl : "\321" # N Tilde + Ctrl : "\321" # N Tilde + Ctrl : "\361" # n Tilde + Ctrl : "\361" # n Tilde + Ctrl : "\322" # O Grave + Ctrl : "\323" # O Acute + Ctrl : "\324" # O Circumflex + Ctrl : "\324" # O Circumflex + Ctrl : "\325" # O Tilde + Ctrl : "\325" # O Tilde + Ctrl : "\326" # O Umlaut + Ctrl : "\330" # O Slash + Ctrl : "\362" # o Grave + Ctrl : "\363" # o Acute + Ctrl : "\364" # o Circumflex + Ctrl : "\364" # o Circumflex + Ctrl : "\365" # o Tilde + Ctrl : "\365" # o Tilde + Ctrl : "\366" # o Umlaut + Ctrl : "\370" # o Slash + Ctrl : "\331" # U Grave + Ctrl : "\332" # U Acute + Ctrl : "\333" # U Circumflex + Ctrl : "\333" # U Circumflex + Ctrl : "\334" # U Umlaut + Ctrl : "\371" # u Grave + Ctrl : "\372" # u Acute + Ctrl : "\373" # u Circumflex + Ctrl : "\373" # u Circumflex + Ctrl : "\374" # u Umlaut + Ctrl : "\337" # German Small Sharp s + Ctrl : "\336" # Capital Icelandic Thor + Ctrl : "\376" # Small Icelandic Thor + Ctrl : "\335" # Y Acute + Ctrl : "\375" # y Acute + Ctrl : "\377" # y Umlaut + # End of Sequence Definition *** /dev/null Tue Mar 9 09:29:28 1993 --- mit/lib/nls/Ximp/iso8859/Imakefile Tue Mar 9 09:29:35 1993 *************** *** 0 **** --- 1,68 ---- + XCOMM $XConsortium: Imakefile,v 1.2 93/02/24 18:02:56 rws Exp $ + + EUC32 = 0 + INSTALLFLAGS = $(INSTDATFLAGS) + + #ifdef XlibI18nPath + XLIBI18N_PATH = XlibI18nPath + #else + XLIBI18N_PATH = $(LIBDIR) + #endif + LCFILES = Codeset + LCFILES1 = Codeset1 + LCFILES2 = Codeset2 + LCFILES3 = Codeset3 + LCFILES5 = Codeset5 + LCFILES7 = Codeset7 + + KSFILES = Compose + + AllTarget($(LCFILES1) $(LCFILES2) $(LCFILES3) $(LCFILES5) $(LCFILES7)) + + CppFileTarget($(LCFILES1), $(LCFILES1).cpp, -DEUC32=$(EUC32), NullParameter) + CppFileTarget($(LCFILES2), $(LCFILES2).cpp, -DEUC32=$(EUC32), NullParameter) + CppFileTarget($(LCFILES3), $(LCFILES3).cpp, -DEUC32=$(EUC32), NullParameter) + CppFileTarget($(LCFILES5), $(LCFILES5).cpp, -DEUC32=$(EUC32), NullParameter) + CppFileTarget($(LCFILES7), $(LCFILES7).cpp, -DEUC32=$(EUC32), NullParameter) + + clean:: + $(RM) $(LCFILES1) $(LCFILES2) $(LCFILES3) $(LCFILES5) $(LCFILES7) + + depend:: + + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/da) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/de) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/en) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/es) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/fi) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/fr) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/is) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/it) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/nl) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/no) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/pt) + InstallNamedNonExec($(LCFILES1),$(LCFILES),$(XLIBI18N_PATH)/sv) + + InstallNamedNonExec($(LCFILES2),$(LCFILES),$(XLIBI18N_PATH)/pl) + InstallNamedNonExec($(LCFILES2),$(LCFILES),$(XLIBI18N_PATH)/sh) + InstallNamedNonExec($(LCFILES2),$(LCFILES),$(XLIBI18N_PATH)/sk) + + InstallNamedNonExec($(LCFILES3),$(LCFILES),$(XLIBI18N_PATH)/tr) + + InstallNamedNonExec($(LCFILES5),$(LCFILES),$(XLIBI18N_PATH)/ru) + + InstallNamedNonExec($(LCFILES7),$(LCFILES),$(XLIBI18N_PATH)/el) + + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/da) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/de) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/en) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/es) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/fi) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/fr) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/is) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/it) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/nl) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/no) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/pt) + InstallNonExecFile($(KSFILES),$(XLIBI18N_PATH)/sv) + *** /tmp/d04537 Tue Mar 9 09:29:53 1993 --- mit/lib/nls/Ximp/ja_JP.EUC/Imakefile Tue Mar 9 09:29:50 1993 *************** *** 1,12 **** INSTALLFLAGS = $(INSTDATFLAGS) LCFILES = Codeset ! all:: depend:: ! InstallMultiple($(LCFILES),$(LIBDIR)/ja_JP.EUC) ! InstallMultiple($(LCFILES),$(LIBDIR)/japanese) ! InstallMultiple($(LCFILES),$(LIBDIR)/japan) ! InstallMultiple($(LCFILES),$(LIBDIR)/ja) --- 1,21 ---- + XCOMM $XConsortium: Imakefile,v 1.3 93/02/24 18:04:14 rws Exp $ + + EUC32 = 0 INSTALLFLAGS = $(INSTDATFLAGS) + #ifdef XlibI18nPath + XLIBI18N_PATH = XlibI18nPath + #else + XLIBI18N_PATH = $(LIBDIR) + #endif LCFILES = Codeset ! AllTarget($(LCFILES)) + CppFileTarget($(LCFILES), $(LCFILES).cpp, -DEUC32=$(EUC32), NullParameter) + + clean:: + $(RM) $(LCFILES) depend:: ! InstallMultiple($(LCFILES),$(XLIBI18N_PATH)/ja_JP.EUC) *** /dev/null Tue Mar 9 09:29:55 1993 --- mit/lib/nls/Ximp/ja_JP.EUC/Codeset.cpp Tue Mar 9 09:30:02 1993 *************** *** 0 **** --- 1,59 ---- + /* $XConsortium: Codeset.cpp,v 1.2 93/02/24 18:04:43 rws Exp $ */ + + NAME EUC + + MB_CUR_MAX 3 + + STATE_DEPEND_ENCODING FALSE + + #if EUC32 + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + #else + WC_ENCODING_MASK 0x00008080 + WC_SHIFT_BITS 8 + #endif + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-1 GL + JISX0201.1976-0 GL + FONT + ISO8859-1 GL + JISX0201.1976-0 GL + + CODESET1 + GR + INITIAL_STATE_GR + LENGTH 2 + #if EUC32 + WC_ENCODING 0x30000000 + #else + WC_ENCODING 0x00008080 + #endif + ENCODING + JISX0208.1983-0 GL + JISX0208.1983-0 GR + JISX0208.1983-1 GL + JISX0208.1983-1 GR + FONT + JISX0208.1983-0 GL + JISX0208.1983-1 GR + + CODESET2 + GR + LENGTH 1 + MB_ENCODING 0x8e + #if EUC32 + WC_ENCODING 0x10000000 + #else + WC_ENCODING 0x00000080 + #endif + ENCODING + JISX0201.1976-0 GR + FONT + JISX0201.1976-0 GR *** /dev/null Tue Mar 9 09:30:07 1993 --- mit/lib/nls/Ximp/ja_JP.JIS/Codeset.cpp Tue Mar 9 09:30:18 1993 *************** *** 0 **** --- 1,61 ---- + /* $XConsortium: Codeset.cpp,v 1.2 93/02/24 18:06:20 rws Exp $ */ + + NAME JIS + + MB_CUR_MAX 5 + + STATE_DEPEND_ENCODING TRUE + + #if EUC32 + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + #else + WC_ENCODING_MASK 0x00008080 + WC_SHIFT_BITS 8 + #endif + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + MB_ENCODING 0x1b 0x28 0x4a + MB_ENCODING 0x1b 0x28 0x42 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-1 GL + JISX0201.1976-0 GL + FONT + ISO8859-1 GL + JISX0201.1976-0 GL + + CODESET1 + GL + LENGTH 2 + MB_ENCODING 0x1b 0x24 0x42 + MB_ENCODING 0x1b 0x24 0x40 + #if EUC32 + WC_ENCODING 0x30000000 + #else + WC_ENCODING 0x00008080 + #endif + ENCODING + JISX0208.1983-0 GL + JISX0208.1983-0 GR + JISX0208.1983-1 GL + JISX0208.1983-1 GR + FONT + JISX0208.1983-0 GL + JISX0208.1983-1 GR + + CODESET2 + GR + LENGTH 1 + #if EUC32 + WC_ENCODING 0x10000000 + #else + WC_ENCODING 0x00000080 + #endif + ENCODING + JISX0201.1976-0 GR + FONT + JISX0201.1976-0 GR *** /dev/null Tue Mar 9 09:30:25 1993 --- mit/lib/nls/Ximp/ja_JP.JIS/Imakefile Tue Mar 9 09:30:31 1993 *************** *** 0 **** --- 1,21 ---- + XCOMM $XConsortium: Imakefile,v 1.2 93/02/24 18:05:50 rws Exp $ + + EUC32 = 0 + INSTALLFLAGS = $(INSTDATFLAGS) + + #ifdef XlibI18nPath + XLIBI18N_PATH = XlibI18nPath + #else + XLIBI18N_PATH = $(LIBDIR) + #endif + LCFILES = Codeset + + AllTarget($(LCFILES)) + + CppFileTarget($(LCFILES), $(LCFILES).cpp, -DEUC32=$(EUC32), NullParameter) + + clean:: + $(RM) $(LCFILES) + depend:: + + InstallMultiple($(LCFILES),$(XLIBI18N_PATH)/ja_JP.JIS) *** /tmp/d04640 Tue Mar 9 09:30:48 1993 --- mit/lib/nls/Ximp/ja_JP.SJIS/Imakefile Tue Mar 9 09:30:45 1993 *************** *** 1,9 **** INSTALLFLAGS = $(INSTDATFLAGS) LCFILES = Codeset ! all:: depend:: ! InstallMultiple($(LCFILES),$(LIBDIR)/ja_JP.SJIS) --- 1,21 ---- + XCOMM $XConsortium: Imakefile,v 1.3 93/02/24 18:07:05 rws Exp $ + + EUC32 = 0 INSTALLFLAGS = $(INSTDATFLAGS) + #ifdef XlibI18nPath + XLIBI18N_PATH = XlibI18nPath + #else + XLIBI18N_PATH = $(LIBDIR) + #endif LCFILES = Codeset ! AllTarget($(LCFILES)) ! CppFileTarget($(LCFILES), $(LCFILES).cpp, -DEUC32=$(EUC32), NullParameter) + clean:: + $(RM) $(LCFILES) + depend:: ! InstallMultiple($(LCFILES),$(XLIBI18N_PATH)/ja_JP.SJIS) *** /dev/null Tue Mar 9 09:30:50 1993 --- mit/lib/nls/Ximp/ja_JP.SJIS/Codeset.cpp Tue Mar 9 09:30:57 1993 *************** *** 0 **** --- 1,58 ---- + /* $XConsortium: Codeset.cpp,v 1.2 93/02/24 18:07:33 rws Exp $ */ + + NAME SJIS + + MB_CUR_MAX 2 + + STATE_DEPEND_ENCODING FALSE + + #if EUC32 + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + #else + WC_ENCODING_MASK 0x00008080 + WC_SHIFT_BITS 8 + #endif + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-1 GL + JISX0201.1976-0 GL + FONT + ISO8859-1 GL + JISX0201.1976-0 GL + + CODESET1 + GR + INITIAL_STATE_GR + LENGTH 2 + #if EUC32 + WC_ENCODING 0x30000000 + #else + WC_ENCODING 0x00008080 + #endif + ENCODING + JISX0208.1983-0 GL + JISX0208.1983-0 GR + JISX0208.1983-1 GL + JISX0208.1983-1 GR + FONT + JISX0208.1983-0 GL + JISX0208.1983-1 GR + + CODESET2 + GR + LENGTH 1 + #if EUC32 + WC_ENCODING 0x10000000 + #else + WC_ENCODING 0x00000080 + #endif + ENCODING + JISX0201.1976-0 GR + FONT + JISX0201.1976-0 GR *** /dev/null Tue Mar 9 09:31:02 1993 --- mit/lib/nls/Ximp/ko/Codeset.cpp Tue Mar 9 09:31:11 1993 *************** *** 0 **** --- 1,40 ---- + /* $XConsortium: Codeset.cpp,v 1.2 93/02/24 18:08:47 rws Exp $ */ + + NAME EUC + + MB_CUR_MAX 2 + + STATE_DEPEND_ENCODING FALSE + + #if EUC32 + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + #else + WC_ENCODING_MASK 0x00008080 + WC_SHIFT_BITS 8 + #endif + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-1 GL + FONT + ISO8859-1 GL + + CODESET1 + GR + INITIAL_STATE_GR + LENGTH 2 + #if EUC32 + WC_ENCODING 0x30000000 + #else + WC_ENCODING 0x00008080 + #endif + ENCODING + KSC5601.1987-0 GL + KSC5601.1987-0 GR + FONT + KSC5601.1987-0 GL *** /dev/null Tue Mar 9 09:31:16 1993 --- mit/lib/nls/Ximp/ko/Imakefile Tue Mar 9 09:31:22 1993 *************** *** 0 **** --- 1,21 ---- + XCOMM $XConsortium: Imakefile,v 1.2 93/02/24 18:08:20 rws Exp $ + + EUC32 = 0 + INSTALLFLAGS = $(INSTDATFLAGS) + + #ifdef XlibI18nPath + XLIBI18N_PATH = XlibI18nPath + #else + XLIBI18N_PATH = $(LIBDIR) + #endif + LCFILES = Codeset + + AllTarget($(LCFILES)) + + CppFileTarget($(LCFILES), $(LCFILES).cpp, -DEUC32=$(EUC32), NullParameter) + clean:: + $(RM) $(LCFILES) + + depend:: + + InstallMultiple($(LCFILES),$(XLIBI18N_PATH)/ko) *** /dev/null Tue Mar 9 09:31:27 1993 --- mit/lib/nls/Ximp/zh/Codeset.cpp Tue Mar 9 09:31:36 1993 *************** *** 0 **** --- 1,32 ---- + /* $XConsortium: Codeset.cpp,v 1.2 93/02/24 18:10:20 rws Exp $ */ + + NAME EUC + + MB_CUR_MAX 2 + + STATE_DEPEND_ENCODING FALSE + + WC_ENCODING_MASK 0x30000000 + WC_SHIFT_BITS 7 + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-1 GL + FONT + ISO8859-1 GL + GB2312.1980-0 GL + + CODESET1 + GR + INITIAL_STATE_GR + LENGTH 2 + WC_ENCODING 0x30000000 + ENCODING + GB2312.1980-0 GL + GB2312.1980-0 GR + FONT + GB2312.1980-0 GL *** /dev/null Tue Mar 9 09:31:41 1993 --- mit/lib/nls/Ximp/zh/Imakefile Tue Mar 9 09:31:47 1993 *************** *** 0 **** --- 1,22 ---- + XCOMM $XConsortium: Imakefile,v 1.2 93/02/24 18:09:51 rws Exp $ + + EUC32 = 0 + INSTALLFLAGS = $(INSTDATFLAGS) + + #ifdef XlibI18nPath + XLIBI18N_PATH = XlibI18nPath + #else + XLIBI18N_PATH = $(LIBDIR) + #endif + LCFILES = Codeset + + AllTarget($(LCFILES)) + + CppFileTarget($(LCFILES), $(LCFILES).cpp, -DEUC32=$(EUC32), NullParameter) + + clean:: + $(RM) $(LCFILES) + + depend:: + + InstallMultiple($(LCFILES),$(XLIBI18N_PATH)/zh) *** /dev/null Tue Mar 9 09:31:52 1993 --- mit/lib/nls/Ximp/zh_TW/Codeset.cpp Tue Mar 9 09:32:01 1993 *************** *** 0 **** --- 1,72 ---- + /* $XConsortium: Codeset.cpp,v 1.2 93/02/24 18:11:31 rws Exp $ */ + + NAME EUC + + MB_CUR_MAX 4 + + STATE_DEPEND_ENCODING FALSE + + WC_ENCODING_MASK 0x3fffc000 + WC_SHIFT_BITS 7 + + CODESET0 + GL + INITIAL_STATE_GL + LENGTH 1 + WC_ENCODING 0x00000000 + ENCODING + ISO8859-1 GL + CNS11643-0 GL + FONT + ISO8859-1 GL + CNS11643-0 GL + + CODESET1 + GR + INITIAL_STATE_GR + LENGTH 2 + WC_ENCODING 0x30000000 + ENCODING + CNS11643-1 GR + FONT + CNS11643-1 GL + + CODESET2 # plane 2 + GR + LENGTH 2 + MB_ENCODING 0x8e 0xa2 + WC_ENCODING 0x10088000 + ENCODING + CNS11643-2 GR + FONT + CNS11643-2 GL + + CODESET3 # plane 14 + GR + LENGTH 2 + MB_ENCODING 0x8e 0xae + WC_ENCODING 0x100b8000 + ENCODING + CNS11643-14 GR + FONT + CNS11643-14 GL + + CODESET4 # plane 15 + GR + LENGTH 2 + MB_ENCODING 0x8e 0xaf + WC_ENCODING 0x100bc000 + ENCODING + CNS11643-15 GR + FONT + CNS11643-15 GL + + CODESET5 # plane 16 + GR + LENGTH 2 + MB_ENCODING 0x8e 0xb0 + WC_ENCODING 0x100c0000 + ENCODING + CNS11643-16 GR + FONT + CNS11643-16 GL *** /dev/null Tue Mar 9 09:32:06 1993 --- mit/lib/nls/Ximp/zh_TW/Imakefile Tue Mar 9 09:32:12 1993 *************** *** 0 **** --- 1,22 ---- + XCOMM $XConsortium: Imakefile,v 1.2 93/02/24 18:11:08 rws Exp $ + + EUC32 = 32 + INSTALLFLAGS = $(INSTDATFLAGS) + + #ifdef XlibI18nPath + XLIBI18N_PATH = XlibI18nPath + #else + XLIBI18N_PATH = $(LIBDIR) + #endif + LCFILES = Codeset + + AllTarget($(LCFILES)) + + CppFileTarget($(LCFILES), $(LCFILES).cpp, -DEUC32=$(EUC32), NullParameter) + + clean:: + $(RM) $(LCFILES) + + depend:: + + InstallMultiple($(LCFILES),$(XLIBI18N_PATH)/zh_TW)