*** Makefile.in.old	Thu Jul  7 16:05:07 1994
--- Makefile.in	Tue Jul 12 11:53:52 1994
***************
*** 77,83 ****
  
  # To change the compiler switches, for example to change from -O
  # to -g, change the following line:
! CFLAGS = -O
  
  # To turn off the security checks that disallow incoming sends when
  # the X server appears to be insecure, reverse the comments on the
--- 77,83 ----
  
  # To change the compiler switches, for example to change from -O
  # to -g, change the following line:
! CFLAGS = -O -DI18N
  
  # To turn off the security checks that disallow incoming sends when
  # the X server appears to be insecure, reverse the comments on the
*** tkBind.c.old	Thu Sep 30 16:37:54 1993
--- tkBind.c	Sun Jul 10 16:42:35 1994
***************
*** 244,250 ****
      {"M",		Mod1Mask,	0},
      {"Mod2",		Mod2Mask,	0},
      {"M2",		Mod2Mask,	0},
!     {"Alt",		Mod2Mask,	0},
      {"Mod3",		Mod3Mask,	0},
      {"M3",		Mod3Mask,	0},
      {"Mod4",		Mod4Mask,	0},
--- 244,250 ----
      {"M",		Mod1Mask,	0},
      {"Mod2",		Mod2Mask,	0},
      {"M2",		Mod2Mask,	0},
!     {"Alt",		Mod3Mask,	0},
      {"Mod3",		Mod3Mask,	0},
      {"M3",		Mod3Mask,	0},
      {"Mod4",		Mod4Mask,	0},
***************
*** 386,394 ****
--- 386,400 ----
   * file:
   */
  
+ #ifdef I18N
+ static char *		ExpandPercents _ANSI_ARGS_((TkWindow *tkwinPtr,
+ 			    char *before, XEvent *eventPtr, KeySym keySym,
+ 			    char *after, int afterSize));
+ #else
  static char *		ExpandPercents _ANSI_ARGS_((char *before,
  			    XEvent *eventPtr, KeySym keySym, char *after,
  			    int afterSize));
+ #endif
  static PatSeq *		FindSequence _ANSI_ARGS_((Tcl_Interp *interp,
  			    BindingTable *bindPtr, ClientData object,
  			    char *eventString, int create,
***************
*** 1072,1079 ****
--- 1078,1090 ----
  	    if (matchPtr->flags & PAT_PERCENTS) {
  		char *p;
      
+ #ifdef I18N
+ 		p = ExpandPercents((TkWindow*)tkwin, matchPtr->command,
+ 			eventPtr, (KeySym) detail, shortSpace, STATIC_SPACE);
+ #else
  		p = ExpandPercents(matchPtr->command, eventPtr,
  			(KeySym) detail, shortSpace, STATIC_SPACE);
+ #endif
  		result = Tcl_GlobalEval(bindPtr->interp, p);
  		if (p != shortSpace) {
  		    ckfree(p);
***************
*** 1776,1782 ****
--- 1787,1798 ----
   */
  
  static char *
+ #ifdef I18N
+ ExpandPercents(tkwinPtr, before, eventPtr, keySym, after, afterSize)
+     TkWindow *tkwinPtr;		/* Needed to get the input context */
+ #else
  ExpandPercents(before, eventPtr, keySym, after, afterSize)
+ #endif
      register char *before;	/* Command containing percent
  				 * expressions to be replaced. */
      register XEvent *eventPtr;	/* X event containing information
***************
*** 2039,2047 ****
--- 2055,2076 ----
  			|| (eventPtr->type == KeyRelease)) {
  		    int numChars;
  
+ #ifdef I18N
+ 		    Status sr;
+ 
+ 		    if (tkwinPtr->xic && eventPtr->type == KeyPress)
+ 			numChars = XmbLookupString(tkwinPtr->xic,
+ 				&eventPtr->xkey, numStorage, NUM_SIZE,
+ 				(KeySym *) NULL, &sr);
+ 		    else
+ 			numChars = XLookupString(&eventPtr->xkey, numStorage,
+ 				NUM_SIZE, (KeySym *) NULL,
+ 				(XComposeStatus *) NULL);
+ #else
  		    numChars = XLookupString(&eventPtr->xkey, numStorage,
  			    NUM_SIZE, (KeySym *) NULL,
  			    (XComposeStatus *) NULL);
+ #endif
  		    numStorage[numChars] = '\0';
  		    string = numStorage;
  		}
*** tk.h.old	Mon Nov 22 00:25:43 1993
--- tk.h	Wed Jul  6 13:16:21 1994
***************
*** 362,367 ****
--- 362,370 ----
      unsigned long dummy7;
      unsigned int flags;
      char *dummy8;
+ #ifdef I18N
+     XIC xic;
+ #endif
      char *dummy9;
      ClientData dummy10;
      int dummy12;
*** tkEvent.c.old	Thu Oct  7 17:59:16 1993
--- tkEvent.c	Thu Jul  7 14:23:43 1994
***************
*** 531,536 ****
--- 531,544 ----
  	return;
      }
  
+ #ifdef I18N
+     /*
+      * See if the input method wants to filter this event
+      */
+     if (XFilterEvent(eventPtr, None))
+ 	return;
+ #endif
+ 
      /* 
       * Next, invoke all the generic event handlers (those that are
       * invoked for all events).  If a generic event handler reports that
*** tkInt.h.old	Thu Oct  7 17:59:20 1993
--- tkInt.h	Sun Jul 10 16:08:26 1994
***************
*** 99,104 ****
--- 99,107 ----
  				 * all of the keys that have modifiers
  				 * associated with them.  Malloc'ed, but
  				 * may be NULL. */
+ #ifdef I18N
+     XIM xim;			/* Input method for this display */
+ #endif
  
      /*
       * Information used by tkError.c only:
***************
*** 417,422 ****
--- 420,429 ----
      TkEventHandler *handlerList;/* First in list of event handlers
  				 * declared for this window, or
  				 * NULL if none. */
+ #ifdef I18N
+     XIC xic;			/* Input context */
+ #endif
+ 
      /*
       * Information related to input focussing (tkFocus.c):
       */
*** tkWindow.c.old	Wed Jul  6 13:15:15 1994
--- tkWindow.c	Sun Jul 10 16:42:28 1994
***************
*** 178,183 ****
--- 178,186 ----
  static TkWindow	*	NewWindow _ANSI_ARGS_((TkDisplay *dispPtr,
  			    int screenNum, TkWindow *parentPtr));
  static void		UnlinkWindow _ANSI_ARGS_((TkWindow *winPtr));
+ #ifdef I18N
+ static XIM		OpenIM _ANSI_ARGS_((Display *display));
+ #endif
  
  /*
   *----------------------------------------------------------------------
***************
*** 354,359 ****
--- 357,365 ----
  	    dispPtr->bindInfoStale = 1;
  	    dispPtr->numModKeyCodes = 0;
  	    dispPtr->modKeyCodes = NULL;
+ #ifdef I18N
+ 	    dispPtr->xim = OpenIM(display);
+ #endif
  	    dispPtr->errorPtr = NULL;
  	    dispPtr->deleteCount = 0;
  	    dispPtr->defaultHandler = NULL;
***************
*** 1164,1170 ****
--- 1170,1190 ----
      winPtr->dirtyAtts = 0;
      winPtr->dirtyChanges = 0;
  
+ #ifdef I18N
      /*
+      * Create an XIC for this window.
+      */
+     if (winPtr->dispPtr->xim) {
+ 	winPtr->xic = XCreateIC(winPtr->dispPtr->xim, XNInputStyle,
+ 				XIMPreeditNothing | XIMStatusNothing,
+ 				XNClientWindow, winPtr->window,
+ 				XNFocusWindow, winPtr->window,
+ 				NULL);
+     } else
+ 	winPtr->xic = NULL;
+ #endif
+ 
+     /*
       * If any siblings higher up in the stacking order have already
       * been created then move this window to its rightful position
       * in the stacking order.
***************
*** 1199,1204 ****
--- 1219,1260 ----
  	DoConfigureNotify(winPtr);
      }
  }
+ 
+ #ifdef I18N
+ /*
+  * This routine creates a new input context.
+  * At the moment it only supports the root preedit style
+  */
+ static XIM
+ OpenIM(display)
+     Display *display;
+ {
+     XIM		xim;
+     int		i;
+     XIMStyles  *xim_styles;
+ 
+     if ( NULL == (xim = XOpenIM(display, NULL, NULL, NULL)))
+ 	return 0;
+ 
+     if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL)
+         || !xim_styles) {
+         XCloseIM(xim);
+         return 0;
+     }
+ 
+     for (i = 0; (unsigned short)i < xim_styles->count_styles; i++)
+ 	if ( (XIMPreeditNothing | XIMStatusNothing)
+ 	     == xim_styles->supported_styles[i])
+ 	    break;
+     XFree(xim_styles);
+     if (i == xim_styles->count_styles) {
+ 	XCloseIM(xim);
+ 	return 0;
+     }
+ 
+     return xim;
+ }
+ #endif
  
  /*
   *--------------------------------------------------------------
