@@ -717,10 +717,23 @@ - (void)setInputMethodEnabled:(BOOL)enabled
717
717
self->imEnabled = enabled;
718
718
}
719
719
720
+ - (void )finishInputMethodComposition
721
+ {
722
+ IMLOG (" finishInputMethodComposition called" );
723
+ [self unmarkText ];
724
+ [self .inputContext discardMarkedText ];
725
+ }
726
+
720
727
/*
721
728
NSTextInputClient protocol implementation follows here.
722
729
*/
723
730
731
+ // Utility function, not part of protocol
732
+ - (void )commitString : (NSString *)aString
733
+ {
734
+ [self ->_delegate notifyInputMethod: aString attr: 4 length: (int )[aString length ] cursor: (int )[aString length ] selectedRange: NSMakeRange (NSNotFound , 0 )];
735
+ }
736
+
724
737
- (void )doCommandBySelector : (SEL )aSelector
725
738
{
726
739
IMLOG (" doCommandBySelector called " );
@@ -733,7 +746,7 @@ - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
733
746
{
734
747
IMLOG (" insertText called with string: %s " , [aString UTF8String ]);
735
748
if ([self ->nsAttrBuffer length ] > 0 || [aString length ] > 1 ) {
736
- [self ->_delegate notifyInputMethod: aString attr: 4 length: ( int )[ aString length ] cursor: ( int )[aString length ] selectedRange: NSMakeRange ( NSNotFound , 0 ) ];
749
+ [self commitString: aString];
737
750
self->shouldProcessKeyEvent = NO ;
738
751
} else {
739
752
self->shouldProcessKeyEvent = YES ;
@@ -760,9 +773,9 @@ - (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replace
760
773
- (void ) unmarkText
761
774
{
762
775
IMLOG (" unmarkText called\n " );
763
- if (self-> nsAttrBuffer != nil && self-> nsAttrBuffer .length != 0 ) {
764
- self-> nsAttrBuffer = [self ->nsAttrBuffer initWithString: @" " ];
765
- [ self ->_delegate notifyInputMethod :@" " attr: 4 length: 0 cursor: 0 selectedRange: NSMakeRange ( NSNotFound , 0 ) ];
776
+ if (nsAttrBuffer.length != 0 ) {
777
+ [self commitString: nsAttrBuffer.string ];
778
+ nsAttrBuffer = [nsAttrBuffer initWithString :@" " ];
766
779
}
767
780
self->shouldProcessKeyEvent = YES ;
768
781
}
0 commit comments