1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-18 03:46:03 +00:00
freebsd-ports/chinese/tk83/files/patch-af
Kevin Lo 2c54b710d9 Chineselized Tk ver. 8.3.0. This version is i18n improvement.
This changes the behavior of Tk on X where X Input Methods (XIM) were
recognized and used without question.
With 8.3, they will be recognized and initialized, but not used unless
XIM is turned on (tk useinputmethods 1).  This should only affect users
users with special input methods, and the new default behavior should
be more beneficial to the average user.

Please repo copy, thanks.
2001-02-22 04:09:59 +00:00

92 lines
2.9 KiB
Plaintext

--- tkUnixKey.c.orig Wed Feb 9 02:13:54 2000
+++ tkUnixKey.c Wed Feb 21 21:27:46 2001
@@ -50,6 +50,10 @@
int len;
Tcl_DString buf;
Status status;
+#if defined(I18N_IMPROVE) && defined(TK_USE_INPUT_METHODS)
+ Bool validString = False;
+ Bool usePreviousComposed = False;
+#endif /* I18N_IMPROVE && TK_USE_INPUT_METHODS */
/*
* Overallocate the dstring to the maximum stack amount.
@@ -59,8 +63,18 @@
Tcl_DStringSetLength(&buf, TCL_DSTRING_STATIC_SIZE-1);
#ifdef TK_USE_INPUT_METHODS
+#ifdef I18N_IMPROVE
+ /*
+ * If there is a valid XIC, must fetch strings here since some
+ * garbages still remain. After the fetching, if
+ * dispPtr->useInputMethods == 0, just trash the strings.
+ * m-hirano
+ */
+ if ((winPtr->inputContext != NULL)
+#else
if (winPtr->dispPtr->useInputMethods
&& (winPtr->inputContext != NULL)
+#endif /* I18N_IMPROVE */
&& (eventPtr->type == KeyPress)) {
len = XmbLookupString(winPtr->inputContext, &eventPtr->xkey,
Tcl_DStringValue(&buf), Tcl_DStringLength(&buf),
@@ -75,12 +89,27 @@
Tcl_DStringValue(&buf), len, (KeySym *) NULL, &status);
}
if ((status != XLookupChars) && (status != XLookupBoth)) {
+#ifdef I18N_IMPROVE
+ if (winPtr->dispPtr->isComposed == 1 &&
+ Tcl_DStringLength(&(winPtr->composedDStr)) > 0 &&
+ winPtr->dispPtr->useInputMethods == 1) {
+ usePreviousComposed = True;
+ }
+#endif /* I18N_IMPROVE */
len = 0;
}
+#ifdef I18N_IMPROVE
+ if (winPtr->dispPtr->useInputMethods == 1) {
+ validString = True;
+ }
+#endif /* I18N_IMPROVE */
} else {
len = XLookupString(&eventPtr->xkey, Tcl_DStringValue(&buf),
Tcl_DStringLength(&buf), (KeySym *) NULL,
(XComposeStatus *) NULL);
+#ifdef I18N_IMPROVE
+ validString = True;
+#endif /* I18N_IMPROVE */
}
#else /* TK_USE_INPUT_METHODS */
len = XLookupString(&eventPtr->xkey, Tcl_DStringValue(&buf),
@@ -89,7 +118,30 @@
#endif /* TK_USE_INPUT_METHODS */
Tcl_DStringSetLength(&buf, len);
+#if defined(I18N_IMPROVE) && defined(TK_USE_INPUT_METHODS)
+ if (validString == True) {
+ if (usePreviousComposed == False) {
+ Tcl_ExternalToUtfDString(winPtr->dispPtr->imEncoding,
+ Tcl_DStringValue(&buf), len, dsPtr);
+ Tcl_DStringFree(&(winPtr->composedDStr));
+ Tcl_DStringInit(&(winPtr->composedDStr));
+ Tcl_DStringAppend(&(winPtr->composedDStr),
+ Tcl_DStringValue(dsPtr),
+ Tcl_DStringLength(dsPtr));
+ } else {
+ Tcl_DStringFree(dsPtr);
+ Tcl_DStringInit(dsPtr);
+ Tcl_DStringAppend(dsPtr,
+ Tcl_DStringValue(&(winPtr->composedDStr)),
+ Tcl_DStringLength(&(winPtr->composedDStr)));
+ }
+ } else {
+ Tcl_DStringFree(dsPtr);
+ Tcl_DStringInit(dsPtr);
+ }
+#else
Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&buf), len, dsPtr);
+#endif /* I18N_IMPROVE && TK_USE_INPUT_METHODS */
Tcl_DStringFree(&buf);
return Tcl_DStringValue(dsPtr);