934 fprintf(stderr, "AWTView InputMethod Selector Called : [insertText]: %s\n", [aString UTF8String]);
935 #endif // IM_DEBUG
936
937 if (fInputMethodLOCKABLE == NULL) {
938 return;
939 }
940
941 // Insert happens at the end of PAH
942 fInPressAndHold = NO;
943
944 // insertText gets called when the user commits text generated from an input method. It also gets
945 // called during ordinary input as well. We only need to send an input method event when we have marked
946 // text, or 'text in progress'. We also need to send the event if we get an insert text out of the blue!
947 // (i.e., when the user uses the Character palette or Inkwell), or when the string to insert is a complex
948 // Unicode value.
949
950 NSMutableString * useString = [self parseString:aString];
951 NSUInteger utf16Length = [useString lengthOfBytesUsingEncoding:NSUTF16StringEncoding];
952 NSUInteger utf8Length = [useString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
953 BOOL aStringIsComplex = NO;
954 if ((utf16Length > 2) ||
955 ((utf8Length > 1) && [self isCodePointInUnicodeBlockNeedingIMEvent:[useString characterAtIndex:0]])) {
956 aStringIsComplex = YES;
957 }
958
959 if ([self hasMarkedText] || !fProcessingKeystroke || aStringIsComplex) {
960 JNIEnv *env = [ThreadUtilities getJNIEnv];
961
962 static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
963 // We need to select the previous glyph so that it is overwritten.
964 if (fPAHNeedsToSelect) {
965 JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
966 fPAHNeedsToSelect = NO;
967 }
968
969 static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V");
970 jstring insertedText = JNFNSToJavaString(env, useString);
971 JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
972 (*env)->DeleteLocalRef(env, insertedText);
973
974 // The input method event will create psuedo-key events for each character in the committed string.
975 // We also don't want to send the character that triggered the insertText, usually a return. [3337563]
1298 }
1299
1300 - (void)setInputMethod:(jobject)inputMethod
1301 {
1302 #ifdef IM_DEBUG
1303 fprintf(stderr, "AWTView InputMethod Selector Called : [setInputMethod]\n");
1304 #endif // IM_DEBUG
1305
1306 JNIEnv *env = [ThreadUtilities getJNIEnv];
1307
1308 // Get rid of the old one
1309 if (fInputMethodLOCKABLE) {
1310 JNFDeleteGlobalRef(env, fInputMethodLOCKABLE);
1311 }
1312
1313 // Save a global ref to the new input method.
1314 if (inputMethod != NULL)
1315 fInputMethodLOCKABLE = JNFNewGlobalRef(env, inputMethod);
1316 else
1317 fInputMethodLOCKABLE = NULL;
1318 }
1319
1320 - (void)abandonInput
1321 {
1322 #ifdef IM_DEBUG
1323 fprintf(stderr, "AWTView InputMethod Selector Called : [abandonInput]\n");
1324 #endif // IM_DEBUG
1325
1326 [ThreadUtilities performOnMainThread:@selector(markedTextAbandoned:) on:[NSInputManager currentInputManager] withObject:self waitUntilDone:YES];
1327 [self unmarkText];
1328 }
1329
1330 /******************************** END NSTextInputClient Protocol ********************************/
1331
1332
1333
1334
1335 @end // AWTView
1336
1337 /*
|
934 fprintf(stderr, "AWTView InputMethod Selector Called : [insertText]: %s\n", [aString UTF8String]);
935 #endif // IM_DEBUG
936
937 if (fInputMethodLOCKABLE == NULL) {
938 return;
939 }
940
941 // Insert happens at the end of PAH
942 fInPressAndHold = NO;
943
944 // insertText gets called when the user commits text generated from an input method. It also gets
945 // called during ordinary input as well. We only need to send an input method event when we have marked
946 // text, or 'text in progress'. We also need to send the event if we get an insert text out of the blue!
947 // (i.e., when the user uses the Character palette or Inkwell), or when the string to insert is a complex
948 // Unicode value.
949
950 NSMutableString * useString = [self parseString:aString];
951 NSUInteger utf16Length = [useString lengthOfBytesUsingEncoding:NSUTF16StringEncoding];
952 NSUInteger utf8Length = [useString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
953 BOOL aStringIsComplex = NO;
954
955 unichar codePoint = [useString characterAtIndex:0];
956
957 #ifdef IM_DEBUG
958 NSLog(@"insertText kbdlayout %@ ",(NSString *)kbdLayout);
959 #endif // IM_DEBUG
960
961 if ((utf16Length > 2) ||
962 ((utf8Length > 1) && [self isCodePointInUnicodeBlockNeedingIMEvent:codePoint]) ||
963 ((codePoint == 0x5c) && ([(NSString *)kbdLayout containsString:@"Kotoeri"]))) {
964 aStringIsComplex = YES;
965 }
966
967 if ([self hasMarkedText] || !fProcessingKeystroke || aStringIsComplex) {
968 JNIEnv *env = [ThreadUtilities getJNIEnv];
969
970 static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
971 // We need to select the previous glyph so that it is overwritten.
972 if (fPAHNeedsToSelect) {
973 JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
974 fPAHNeedsToSelect = NO;
975 }
976
977 static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V");
978 jstring insertedText = JNFNSToJavaString(env, useString);
979 JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
980 (*env)->DeleteLocalRef(env, insertedText);
981
982 // The input method event will create psuedo-key events for each character in the committed string.
983 // We also don't want to send the character that triggered the insertText, usually a return. [3337563]
1306 }
1307
1308 - (void)setInputMethod:(jobject)inputMethod
1309 {
1310 #ifdef IM_DEBUG
1311 fprintf(stderr, "AWTView InputMethod Selector Called : [setInputMethod]\n");
1312 #endif // IM_DEBUG
1313
1314 JNIEnv *env = [ThreadUtilities getJNIEnv];
1315
1316 // Get rid of the old one
1317 if (fInputMethodLOCKABLE) {
1318 JNFDeleteGlobalRef(env, fInputMethodLOCKABLE);
1319 }
1320
1321 // Save a global ref to the new input method.
1322 if (inputMethod != NULL)
1323 fInputMethodLOCKABLE = JNFNewGlobalRef(env, inputMethod);
1324 else
1325 fInputMethodLOCKABLE = NULL;
1326
1327 kbdLayout = TISGetInputSourceProperty(TISCopyCurrentKeyboardInputSource(), kTISPropertyInputSourceID);
1328 }
1329
1330 - (void)abandonInput
1331 {
1332 #ifdef IM_DEBUG
1333 fprintf(stderr, "AWTView InputMethod Selector Called : [abandonInput]\n");
1334 #endif // IM_DEBUG
1335
1336 [ThreadUtilities performOnMainThread:@selector(markedTextAbandoned:) on:[NSInputManager currentInputManager] withObject:self waitUntilDone:YES];
1337 [self unmarkText];
1338 }
1339
1340 /******************************** END NSTextInputClient Protocol ********************************/
1341
1342
1343
1344
1345 @end // AWTView
1346
1347 /*
|