diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index cf00cdfb67..158d7b3880 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -227,9 +227,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, [NSNumber numberWithBool:NO], MMVerticalSplitKey, [NSNumber numberWithInt:0], MMPreloadCacheSizeKey, [NSNumber numberWithInt:0], MMLastWindowClosedBehaviorKey, -#ifdef INCLUDE_OLD_IM_CODE - [NSNumber numberWithBool:YES], MMUseInlineImKey, -#endif // INCLUDE_OLD_IM_CODE [NSNumber numberWithBool:NO], MMSuppressTerminationAlertKey, [NSNumber numberWithBool:YES], MMNativeFullScreenKey, [NSNumber numberWithDouble:0.25], MMFullScreenFadeTimeKey, diff --git a/src/MacVim/MMCoreTextView.h b/src/MacVim/MMCoreTextView.h index a085013057..c606310317 100644 --- a/src/MacVim/MMCoreTextView.h +++ b/src/MacVim/MMCoreTextView.h @@ -87,6 +87,7 @@ - (void)setLigatures:(BOOL)state; - (void)setThinStrokes:(BOOL)state; - (void)setImControl:(BOOL)enable; +- (void)setInlineIm:(BOOL)enable; - (void)activateIm:(BOOL)enable; - (void)checkImState; - (BOOL)convertPoint:(NSPoint)point toRow:(int *)row column:(int *)column; diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index 9ee0f654e1..e708b50ba8 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -425,6 +425,11 @@ defaultAdvanceForFont(NSFont *font) [helper setImControl:enable]; } +- (void)setInlineIm:(BOOL)enable +{ + [helper setInlineIm:enable]; +} + - (void)activateIm:(BOOL)enable { [helper activateIm:enable]; diff --git a/src/MacVim/MMTextView.h b/src/MacVim/MMTextView.h index 6938dc97fa..e53735989a 100644 --- a/src/MacVim/MMTextView.h +++ b/src/MacVim/MMTextView.h @@ -37,6 +37,7 @@ - (void)setLigatures:(BOOL)ligatures; - (void)setThinStrokes:(BOOL)thinStrokes; - (void)setImControl:(BOOL)enable; +- (void)setInlineIm:(BOOL)enable; - (void)activateIm:(BOOL)enable; - (void)checkImState; diff --git a/src/MacVim/MMTextView.m b/src/MacVim/MMTextView.m index aa16b5f1ff..a2724e615e 100644 --- a/src/MacVim/MMTextView.m +++ b/src/MacVim/MMTextView.m @@ -322,6 +322,11 @@ [helper setImControl:enable]; } +- (void)setInlineIm:(BOOL)enable +{ + [helper setInlineIm:enable]; +} + - (void)activateIm:(BOOL)enable { [helper activateIm:enable]; @@ -557,8 +562,7 @@ numInvertRects = 0; } -#ifdef INCLUDE_OLD_IM_CODE - if ([self hasMarkedText] && ![helper useInlineIm]) { + if ([self hasMarkedText] && ![helper inlineIm]) { shouldDrawInsertionPoint = YES; MMTextStorage *ts = (MMTextStorage*)[self textStorage]; NSSize inset = [self textContainerInset]; @@ -616,7 +620,6 @@ } } } -#endif // INCLUDE_OLD_IM_CODE if (shouldDrawInsertionPoint) { MMTextStorage *ts = (MMTextStorage*)[self textStorage]; @@ -626,9 +629,8 @@ ipRect.origin.x += [self textContainerOrigin].x; ipRect.origin.y += [self textContainerOrigin].y; -#ifdef INCLUDE_OLD_IM_CODE // Draw insertion point inside marked text. - if ([self hasMarkedText] && ![helper useInlineIm]) { + if ([self hasMarkedText] && ![helper inlineIm]) { NSFont *theFont = [[self markedTextAttributes] valueForKey:NSFontAttributeName]; if (theFont == [ts font]) @@ -640,7 +642,6 @@ ([helper imRange].location + [helper imRange].length); } -#endif // INCLUDE_OLD_IM_CODE if (MMInsertionPointHorizontal == insertionPointShape) { int frac = ([ts cellSize].height * insertionPointFraction + 99)/100; diff --git a/src/MacVim/MMTextViewHelper.h b/src/MacVim/MMTextViewHelper.h index bb3d3dd5b5..8ba49540e9 100644 --- a/src/MacVim/MMTextViewHelper.h +++ b/src/MacVim/MMTextViewHelper.h @@ -45,6 +45,7 @@ NSMutableAttributedString *markedText; int preEditRow; int preEditColumn; + BOOL inlineIm; BOOL imControl; BOOL imState; TISInputSourceRef lastImSource; @@ -90,7 +91,8 @@ - (NSRect)firstRectForCharacterRange:(NSRange)range; - (void)setImControl:(BOOL)enable; - (void)activateIm:(BOOL)enable; -- (BOOL)useInlineIm; +- (void)setInlineIm:(BOOL)enable; +- (BOOL)inlineIm; - (void)checkImState; @end diff --git a/src/MacVim/MMTextViewHelper.m b/src/MacVim/MMTextViewHelper.m index 838bbeb059..e1d9c2202a 100644 --- a/src/MacVim/MMTextViewHelper.m +++ b/src/MacVim/MMTextViewHelper.m @@ -616,7 +616,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) ASLogDebug(@"text='%@' range=%@", text, NSStringFromRange(range)); [self unmarkText]; - if ([self useInlineIm]) { + if (inlineIm) { if ([text isKindOfClass:[NSAttributedString class]]) text = [text string]; @@ -629,7 +629,6 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) return; } -#ifdef INCLUDE_OLD_IM_CODE if (!(text && [text length] > 0)) return; @@ -669,7 +668,6 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) } [textView setNeedsDisplay:YES]; -#endif // INCLUDE_OLD_IM_CODE } - (void)unmarkText @@ -813,14 +811,14 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) } } -- (BOOL)useInlineIm +- (void)setInlineIm:(BOOL)enable { -#ifdef INCLUDE_OLD_IM_CODE - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - return [ud boolForKey:MMUseInlineImKey]; -#else - return YES; -#endif // INCLUDE_OLD_IM_CODE + inlineIm = enable; +} + +- (BOOL)inlineIm +{ + return inlineIm; } - (void)checkImState @@ -1064,7 +1062,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b) - (void)sendMarkedText:(NSString *)text position:(int32_t)pos { - if (![self useInlineIm]) + if (!inlineIm) return; NSMutableData *data = [NSMutableData data]; diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index 66d4b4b556..c61c521f8c 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -833,6 +833,10 @@ static BOOL isUnsafeMessage(int msgid); [[[windowController vimView] textView] activateIm:YES]; } else if (DeactivateKeyScriptMsgID == msgid) { [[[windowController vimView] textView] activateIm:NO]; + } else if (EnableInlineImMsgID == msgid) { + [[[windowController vimView] textView] setInlineIm:YES]; + } else if (DisableInlineImMsgID == msgid) { + [[[windowController vimView] textView] setInlineIm:NO]; } else if (EnableImControlMsgID == msgid) { [[[windowController vimView] textView] setImControl:YES]; } else if (DisableImControlMsgID == msgid) { diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index 2a8a53f588..c4df1d8762 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -251,6 +251,8 @@ enum { DisableLigaturesMsgID, EnableThinStrokesMsgID, DisableThinStrokesMsgID, + EnableInlineImMsgID, + DisableInlineImMsgID, LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM! }; diff --git a/src/MacVim/MacVim.m b/src/MacVim/MacVim.m index b9fdeb43c9..0b43c6fd92 100644 --- a/src/MacVim/MacVim.m +++ b/src/MacVim/MacVim.m @@ -105,6 +105,8 @@ char *MessageStrings[] = "DisableLigaturesMsgID", "EnableThinStrokesMsgID", "DisableThinStrokesMsgID", + "EnableInlineImMsgID", + "DisableInlineImMsgID", "END OF MESSAGE IDs" // NOTE: Must be last! }; diff --git a/src/MacVim/Miscellaneous.h b/src/MacVim/Miscellaneous.h index 68380bb99a..73d74abcf0 100644 --- a/src/MacVim/Miscellaneous.h +++ b/src/MacVim/Miscellaneous.h @@ -13,10 +13,6 @@ #import "MacVim.h" -// TODO: Remove this when the inline IM code has been tested -#define INCLUDE_OLD_IM_CODE - - // NSUserDefaults keys extern NSString *MMTabMinWidthKey; extern NSString *MMTabMaxWidthKey; @@ -45,9 +41,6 @@ extern NSString *MMOpenLayoutKey; extern NSString *MMVerticalSplitKey; extern NSString *MMPreloadCacheSizeKey; extern NSString *MMLastWindowClosedBehaviorKey; -#ifdef INCLUDE_OLD_IM_CODE -extern NSString *MMUseInlineImKey; -#endif // INCLUDE_OLD_IM_CODE extern NSString *MMSuppressTerminationAlertKey; extern NSString *MMNativeFullScreenKey; extern NSString *MMUseMouseTimeKey; diff --git a/src/MacVim/Miscellaneous.m b/src/MacVim/Miscellaneous.m index 5351e43d25..52deb0119e 100644 --- a/src/MacVim/Miscellaneous.m +++ b/src/MacVim/Miscellaneous.m @@ -41,9 +41,6 @@ NSString *MMOpenLayoutKey = @"MMOpenLayout"; NSString *MMVerticalSplitKey = @"MMVerticalSplit"; NSString *MMPreloadCacheSizeKey = @"MMPreloadCacheSize"; NSString *MMLastWindowClosedBehaviorKey = @"MMLastWindowClosedBehavior"; -#ifdef INCLUDE_OLD_IM_CODE -NSString *MMUseInlineImKey = @"MMUseInlineIm"; -#endif // INCLUDE_OLD_IM_CODE NSString *MMSuppressTerminationAlertKey = @"MMSuppressTerminationAlert"; NSString *MMNativeFullScreenKey = @"MMNativeFullScreen"; NSString *MMUseMouseTimeKey = @"MMUseMouseTime"; diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index f2e4a8330e..a79ec6d4cc 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -264,6 +264,8 @@ gui_mch_init(void) gui_mch_adjust_charheight(); gui_mch_adjust_charwidth(); + gui_macvim_set_imstyle(p_imst); + if (!MMNoMRU && GARGCOUNT > 0) { // Add files passed on command line to MRU. NSMutableArray *filenames = [NSMutableArray array]; @@ -1331,6 +1333,15 @@ im_get_status(void) + void +gui_macvim_set_imstyle(long imstyle) +{ + int msgid = imstyle == IM_ON_THE_SPOT ? + EnableInlineImMsgID : DisableInlineImMsgID; + [[MMBackend sharedInstance] queueMessage:msgid properties:nil]; +} + + // -- Find & Replace dialog ------------------------------------------------- diff --git a/src/option.c b/src/option.c index 950c68615f..621ef0544c 100644 --- a/src/option.c +++ b/src/option.c @@ -9085,6 +9085,9 @@ set_num_option( { if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT) errmsg = e_invarg; +# ifdef FEAT_GUI_MACVIM + gui_macvim_set_imstyle(p_imst); +# endif } #endif diff --git a/src/proto/gui_macvim.pro b/src/proto/gui_macvim.pro index b2d2f2e49d..62b94c3cd1 100644 --- a/src/proto/gui_macvim.pro +++ b/src/proto/gui_macvim.pro @@ -235,6 +235,8 @@ gui_mch_find_dialog(exarg_T *eap); gui_mch_replace_dialog(exarg_T *eap); void im_set_control(int enable); + void +gui_macvim_set_imstyle(long imstyle); void * gui_macvim_add_channel(channel_T *channel, ch_part_T part);