Control InlineIM by imstyle

This commit is contained in:
Kazuki Sakamoto
2017-08-30 19:34:33 -07:00
parent 5cba1fc864
commit d23c46d07e
15 changed files with 50 additions and 31 deletions
-3
View File
@@ -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,
+1
View File
@@ -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;
+5
View File
@@ -425,6 +425,11 @@ defaultAdvanceForFont(NSFont *font)
[helper setImControl:enable];
}
- (void)setInlineIm:(BOOL)enable
{
[helper setInlineIm:enable];
}
- (void)activateIm:(BOOL)enable
{
[helper activateIm:enable];
+1
View File
@@ -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;
+7 -6
View File
@@ -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;
+3 -1
View File
@@ -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
+9 -11
View File
@@ -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];
+4
View File
@@ -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) {
+2
View File
@@ -251,6 +251,8 @@ enum {
DisableLigaturesMsgID,
EnableThinStrokesMsgID,
DisableThinStrokesMsgID,
EnableInlineImMsgID,
DisableInlineImMsgID,
LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM!
};
+2
View File
@@ -105,6 +105,8 @@ char *MessageStrings[] =
"DisableLigaturesMsgID",
"EnableThinStrokesMsgID",
"DisableThinStrokesMsgID",
"EnableInlineImMsgID",
"DisableInlineImMsgID",
"END OF MESSAGE IDs" // NOTE: Must be last!
};
-7
View File
@@ -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;
-3
View File
@@ -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";
+11
View File
@@ -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 -------------------------------------------------
+3
View File
@@ -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
+2
View File
@@ -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);