Compare commits

...

3 Commits

Author SHA1 Message Date
Kazuki Sakamoto 4dd200f7ac Draw markedText in MMCoreTextView if imstyle=1 2017-09-20 19:13:23 -07:00
Kazuki Sakamoto ff28b66f41 Remove InlineIM from Preferences 2017-09-20 19:13:23 -07:00
Kazuki Sakamoto d23c46d07e Control InlineIM by imstyle 2017-09-20 19:13:23 -07:00
18 changed files with 161 additions and 65 deletions
+15 -34
View File
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1611" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies> <dependencies>
<deployment version="1050" identifier="macosx"/> <deployment version="1050" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="MMPreferenceController"> <customObject id="-2" userLabel="File's Owner" customClass="MMPreferenceController">
@@ -13,7 +14,7 @@
</connections> </connections>
</customObject> </customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/>
<userDefaultsController representsSharedInstance="YES" id="58" userLabel="Shared Defaults"/> <userDefaultsController representsSharedInstance="YES" id="58" userLabel="Shared Defaults"/>
<customView id="115" userLabel="General"> <customView id="115" userLabel="General">
<rect key="frame" x="0.0" y="0.0" width="483" height="290"/> <rect key="frame" x="0.0" y="0.0" width="483" height="290"/>
@@ -24,7 +25,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Keep MacVim Running" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="960" id="979"> <popUpButtonCell key="cell" type="push" title="Keep MacVim Running" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="960" id="979">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="959"> <menu key="menu" title="OtherViews" id="959">
<items> <items>
<menuItem title="Keep MacVim Running" state="on" id="960"/> <menuItem title="Keep MacVim Running" state="on" id="960"/>
@@ -51,7 +52,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="and set the arglist" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="436" id="978"> <popUpButtonCell key="cell" type="push" title="and set the arglist" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" selectedItem="436" id="978">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="429"> <menu key="menu" title="OtherViews" id="429">
<items> <items>
<menuItem title="with a tab for each file" tag="3" id="430"/> <menuItem title="with a tab for each file" tag="3" id="430"/>
@@ -180,12 +181,12 @@
</textField> </textField>
</subviews> </subviews>
</customView> </customView>
<customView id="620" userLabel="Advanced"> <customView misplaced="YES" id="620" userLabel="Advanced">
<rect key="frame" x="0.0" y="0.0" width="483" height="318"/> <rect key="frame" x="0.0" y="0.0" width="483" height="222"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" id="826"> <textField verticalHuggingPriority="750" id="826">
<rect key="frame" x="17" y="170" width="449" height="56"/> <rect key="frame" x="17" y="74" width="449" height="56"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="993"> <textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="993">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
@@ -195,7 +196,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<button id="817"> <button id="817">
<rect key="frame" x="18" y="228" width="133" height="18"/> <rect key="frame" x="18" y="132" width="133" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Enable Quickstart" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="992"> <buttonCell key="cell" type="check" title="Enable Quickstart" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="992">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -207,7 +208,7 @@
</connections> </connections>
</button> </button>
<textField verticalHuggingPriority="750" id="815"> <textField verticalHuggingPriority="750" id="815">
<rect key="frame" x="17" y="252" width="449" height="28"/> <rect key="frame" x="17" y="156" width="449" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="991"> <textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="991">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
@@ -217,7 +218,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<button id="782"> <button id="782">
<rect key="frame" x="18" y="282" width="174" height="18"/> <rect key="frame" x="18" y="186" width="174" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Use Core Text renderer" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="990"> <buttonCell key="cell" type="check" title="Use Core Text renderer" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="990">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -228,28 +229,7 @@
<binding destination="58" name="value" keyPath="values.MMRenderer" id="1000"/> <binding destination="58" name="value" keyPath="values.MMRenderer" id="1000"/>
</connections> </connections>
</button> </button>
<textField verticalHuggingPriority="750" id="1001"> <textField verticalHuggingPriority="750" misplaced="YES" id="1017">
<rect key="frame" x="17" y="74" width="444" height="70"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="1004">
<font key="font" metaFont="smallSystem"/>
<string key="title">This option causes marked text to be rendered like normal text which is very convenient when using a complex input method (e.g. Kotoeri). However, it has some known limitations which may be circumvented by disabling this option (e.g. mapping to "dead keys" may not work). Note that without this option the Core Text renderer will not draw marked text at all.</string>
<color key="textColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button id="1013">
<rect key="frame" x="18" y="146" width="174" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Draw marked text inline" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="1014">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="58" name="value" keyPath="values.MMUseInlineIm" id="1016"/>
</connections>
</button>
<textField verticalHuggingPriority="750" id="1017">
<rect key="frame" x="17" y="20" width="415" height="28"/> <rect key="frame" x="17" y="20" width="415" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="1020"> <textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="1020">
@@ -259,7 +239,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<button id="1028"> <button misplaced="YES" id="1028">
<rect key="frame" x="18" y="50" width="388" height="18"/> <rect key="frame" x="18" y="50" width="388" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Prefer native full-screen support (requires Mac OS X 10.7)" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="1029"> <buttonCell key="cell" type="check" title="Prefer native full-screen support (requires Mac OS X 10.7)" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="1029">
@@ -271,6 +251,7 @@
</connections> </connections>
</button> </button>
</subviews> </subviews>
<point key="canvasLocation" x="54.5" y="-249"/>
</customView> </customView>
</objects> </objects>
</document> </document>
Binary file not shown.
-3
View File
@@ -227,9 +227,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
[NSNumber numberWithBool:NO], MMVerticalSplitKey, [NSNumber numberWithBool:NO], MMVerticalSplitKey,
[NSNumber numberWithInt:0], MMPreloadCacheSizeKey, [NSNumber numberWithInt:0], MMPreloadCacheSizeKey,
[NSNumber numberWithInt:0], MMLastWindowClosedBehaviorKey, [NSNumber numberWithInt:0], MMLastWindowClosedBehaviorKey,
#ifdef INCLUDE_OLD_IM_CODE
[NSNumber numberWithBool:YES], MMUseInlineImKey,
#endif // INCLUDE_OLD_IM_CODE
[NSNumber numberWithBool:NO], MMSuppressTerminationAlertKey, [NSNumber numberWithBool:NO], MMSuppressTerminationAlertKey,
[NSNumber numberWithBool:YES], MMNativeFullScreenKey, [NSNumber numberWithBool:YES], MMNativeFullScreenKey,
[NSNumber numberWithDouble:0.25], MMFullScreenFadeTimeKey, [NSNumber numberWithDouble:0.25], MMFullScreenFadeTimeKey,
+13
View File
@@ -2092,6 +2092,8 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
[self setImState:NO]; [self setImState:NO];
} else if (BackingPropertiesChangedMsgID == msgid) { } else if (BackingPropertiesChangedMsgID == msgid) {
[self redrawScreen]; [self redrawScreen];
} else if (RedrawBlockMsgID == msgid) {
[self handleRedrawBlock:data];
} else { } else {
ASLogWarn(@"Unknown message received (msgid=%d)", msgid); ASLogWarn(@"Unknown message received (msgid=%d)", msgid);
} }
@@ -3008,6 +3010,17 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
} }
} }
- (void)handleRedrawBlock:(NSData *)data
{
const void *bytes = [data bytes];
int row1 = *((int*)bytes); bytes += sizeof(int);
int col1 = *((int*)bytes); bytes += sizeof(int);
int row2 = *((int*)bytes); bytes += sizeof(int);
int col2 = *((int*)bytes);
gui_redraw_block(row1, col1, row2, col2, GUI_MON_NOCLEAR);
}
#ifdef FEAT_BEVAL #ifdef FEAT_BEVAL
- (void)bevalCallback:(id)sender - (void)bevalCallback:(id)sender
{ {
+10
View File
@@ -18,6 +18,8 @@
int maxRows, maxColumns; int maxRows, maxColumns;
NSColor *defaultBackgroundColor; NSColor *defaultBackgroundColor;
NSColor *defaultForegroundColor; NSColor *defaultForegroundColor;
int defaultBackgroundHexColor;
int defaultForegroundHexColor;
NSSize cellSize; NSSize cellSize;
NSFont *font; NSFont *font;
NSFont *fontWide; NSFont *fontWide;
@@ -51,6 +53,12 @@
void *trackingRectUserData_; void *trackingRectUserData_;
NSTrackingRectTag lastToolTipTag_; NSTrackingRectTag lastToolTipTag_;
NSString* toolTip_; NSString* toolTip_;
NSUInteger markedRangeLength;
int markedTextStartRow;
int markedTextStartColumn;
int markedTextEndRow;
int markedTextEndColumn;
} }
- (id)initWithFrame:(NSRect)frame; - (id)initWithFrame:(NSRect)frame;
@@ -87,8 +95,10 @@
- (void)setLigatures:(BOOL)state; - (void)setLigatures:(BOOL)state;
- (void)setThinStrokes:(BOOL)state; - (void)setThinStrokes:(BOOL)state;
- (void)setImControl:(BOOL)enable; - (void)setImControl:(BOOL)enable;
- (void)setInlineIm:(BOOL)enable;
- (void)activateIm:(BOOL)enable; - (void)activateIm:(BOOL)enable;
- (void)checkImState; - (void)checkImState;
- (void)clearMarkedText;
- (BOOL)convertPoint:(NSPoint)point toRow:(int *)row column:(int *)column; - (BOOL)convertPoint:(NSPoint)point toRow:(int *)row column:(int *)column;
- (NSRect)rectForRow:(int)row column:(int)column numRows:(int)nr - (NSRect)rectForRow:(int)row column:(int)column numRows:(int)nr
numColumns:(int)nc; numColumns:(int)nc;
+70
View File
@@ -205,6 +205,13 @@ defaultAdvanceForFont(NSFont *font)
if (defaultBackgroundColor != bgColor) { if (defaultBackgroundColor != bgColor) {
[defaultBackgroundColor release]; [defaultBackgroundColor release];
defaultBackgroundColor = bgColor ? [bgColor retain] : nil; defaultBackgroundColor = bgColor ? [bgColor retain] : nil;
if (bgColor) {
defaultBackgroundHexColor =
(int)(bgColor.blueComponent * 0xff) |
((int)(bgColor.greenComponent * 0xff) << 8) |
((int)(bgColor.redComponent * 0xff) << 16) |
(0xff << 24);
}
} }
// NOTE: The default foreground color isn't actually used for anything, but // NOTE: The default foreground color isn't actually used for anything, but
@@ -213,6 +220,13 @@ defaultAdvanceForFont(NSFont *font)
if (defaultForegroundColor != fgColor) { if (defaultForegroundColor != fgColor) {
[defaultForegroundColor release]; [defaultForegroundColor release];
defaultForegroundColor = fgColor ? [fgColor retain] : nil; defaultForegroundColor = fgColor ? [fgColor retain] : nil;
if (fgColor) {
defaultForegroundHexColor =
(int)(fgColor.blueComponent * 0xff) |
((int)(fgColor.greenComponent * 0xff) << 8) |
((int)(fgColor.redComponent * 0xff) << 16) |
(0xff << 24);
}
} }
} }
@@ -425,6 +439,11 @@ defaultAdvanceForFont(NSFont *font)
[helper setImControl:enable]; [helper setImControl:enable];
} }
- (void)setInlineIm:(BOOL)enable
{
[helper setInlineIm:enable];
}
- (void)activateIm:(BOOL)enable - (void)activateIm:(BOOL)enable
{ {
[helper activateIm:enable]; [helper activateIm:enable];
@@ -494,6 +513,23 @@ defaultAdvanceForFont(NSFont *font)
[helper setMarkedText:text selectedRange:range]; [helper setMarkedText:text selectedRange:range];
} }
- (void)clearMarkedText
{
if (![helper inlineIm]) {
[self redrawMarkedTextBlock];
}
}
- (void)redrawMarkedTextBlock
{
NSMutableData *data = [NSMutableData data];
[data appendBytes:&markedTextStartRow length:sizeof(int)];
[data appendBytes:&markedTextStartColumn length:sizeof(int)];
[data appendBytes:&markedTextEndRow length:sizeof(int)];
[data appendBytes:&markedTextEndColumn length:sizeof(int)];
[[self vimController] sendMessage:RedrawBlockMsgID data:data];
}
- (void)unmarkText - (void)unmarkText
{ {
[helper unmarkText]; [helper unmarkText];
@@ -647,6 +683,40 @@ defaultAdvanceForFont(NSFont *font)
[drawData removeAllObjects]; [drawData removeAllObjects];
} }
if ([helper hasMarkedText] && ![helper inlineIm]) {
NSString *text = [[helper markedText] string];
// Draw marked text
CFStringRef sref = (__bridge CFStringRef)text;
CFIndex unilength = CFStringGetLength(sref);
const UniChar *unichars = CFStringGetCharactersPtr(sref);
UniChar *buffer = NULL;
if (unichars == NULL) {
buffer = malloc(unilength * sizeof(UniChar));
CFStringGetCharacters(sref, CFRangeMake(0, unilength), buffer);
unichars = buffer;
}
int row = [helper preEditRow];
int col = [helper preEditColumn];
markedTextStartRow = row;
markedTextEndRow = row;
markedTextStartColumn = col;
markedTextEndColumn = col + unilength * 2;
[self drawString:unichars length:unilength
atRow:row column:col cells:(unilength * 2)
withFlags:(DRAW_WIDE|DRAW_UNDERL)
foregroundColor:defaultForegroundHexColor
backgroundColor:defaultBackgroundHexColor
specialColor:defaultForegroundHexColor];
if (buffer) {
free(buffer);
buffer = NULL;
}
}
} }
- (void)performBatchDrawWithData:(NSData *)data - (void)performBatchDrawWithData:(NSData *)data
+2
View File
@@ -37,6 +37,7 @@
- (void)setLigatures:(BOOL)ligatures; - (void)setLigatures:(BOOL)ligatures;
- (void)setThinStrokes:(BOOL)thinStrokes; - (void)setThinStrokes:(BOOL)thinStrokes;
- (void)setImControl:(BOOL)enable; - (void)setImControl:(BOOL)enable;
- (void)setInlineIm:(BOOL)enable;
- (void)activateIm:(BOOL)enable; - (void)activateIm:(BOOL)enable;
- (void)checkImState; - (void)checkImState;
@@ -74,4 +75,5 @@
- (void)deleteSign:(NSString *)signName; - (void)deleteSign:(NSString *)signName;
- (void)setToolTipAtMousePoint:(NSString *)string; - (void)setToolTipAtMousePoint:(NSString *)string;
- (void)setCGLayerEnabled:(BOOL)enabled; - (void)setCGLayerEnabled:(BOOL)enabled;
- (void)clearMarkedText;
@end @end
+11 -6
View File
@@ -322,6 +322,11 @@
[helper setImControl:enable]; [helper setImControl:enable];
} }
- (void)setInlineIm:(BOOL)enable
{
[helper setInlineIm:enable];
}
- (void)activateIm:(BOOL)enable - (void)activateIm:(BOOL)enable
{ {
[helper activateIm:enable]; [helper activateIm:enable];
@@ -557,8 +562,7 @@
numInvertRects = 0; numInvertRects = 0;
} }
#ifdef INCLUDE_OLD_IM_CODE if ([self hasMarkedText] && ![helper inlineIm]) {
if ([self hasMarkedText] && ![helper useInlineIm]) {
shouldDrawInsertionPoint = YES; shouldDrawInsertionPoint = YES;
MMTextStorage *ts = (MMTextStorage*)[self textStorage]; MMTextStorage *ts = (MMTextStorage*)[self textStorage];
NSSize inset = [self textContainerInset]; NSSize inset = [self textContainerInset];
@@ -616,7 +620,6 @@
} }
} }
} }
#endif // INCLUDE_OLD_IM_CODE
if (shouldDrawInsertionPoint) { if (shouldDrawInsertionPoint) {
MMTextStorage *ts = (MMTextStorage*)[self textStorage]; MMTextStorage *ts = (MMTextStorage*)[self textStorage];
@@ -626,9 +629,8 @@
ipRect.origin.x += [self textContainerOrigin].x; ipRect.origin.x += [self textContainerOrigin].x;
ipRect.origin.y += [self textContainerOrigin].y; ipRect.origin.y += [self textContainerOrigin].y;
#ifdef INCLUDE_OLD_IM_CODE
// Draw insertion point inside marked text. // Draw insertion point inside marked text.
if ([self hasMarkedText] && ![helper useInlineIm]) { if ([self hasMarkedText] && ![helper inlineIm]) {
NSFont *theFont = [[self markedTextAttributes] NSFont *theFont = [[self markedTextAttributes]
valueForKey:NSFontAttributeName]; valueForKey:NSFontAttributeName];
if (theFont == [ts font]) if (theFont == [ts font])
@@ -640,7 +642,6 @@
([helper imRange].location + ([helper imRange].location +
[helper imRange].length); [helper imRange].length);
} }
#endif // INCLUDE_OLD_IM_CODE
if (MMInsertionPointHorizontal == insertionPointShape) { if (MMInsertionPointHorizontal == insertionPointShape) {
int frac = ([ts cellSize].height * insertionPointFraction + 99)/100; int frac = ([ts cellSize].height * insertionPointFraction + 99)/100;
@@ -730,6 +731,10 @@
[helper unmarkText]; [helper unmarkText];
} }
- (void)clearMarkedText
{
}
- (NSRect)firstRectForCharacterRange:(NSRange)range - (NSRect)firstRectForCharacterRange:(NSRange)range
{ {
return [helper firstRectForCharacterRange:range]; return [helper firstRectForCharacterRange:range];
+3 -1
View File
@@ -45,6 +45,7 @@
NSMutableAttributedString *markedText; NSMutableAttributedString *markedText;
int preEditRow; int preEditRow;
int preEditColumn; int preEditColumn;
BOOL inlineIm;
BOOL imControl; BOOL imControl;
BOOL imState; BOOL imState;
TISInputSourceRef lastImSource; TISInputSourceRef lastImSource;
@@ -90,7 +91,8 @@
- (NSRect)firstRectForCharacterRange:(NSRange)range; - (NSRect)firstRectForCharacterRange:(NSRange)range;
- (void)setImControl:(BOOL)enable; - (void)setImControl:(BOOL)enable;
- (void)activateIm:(BOOL)enable; - (void)activateIm:(BOOL)enable;
- (BOOL)useInlineIm; - (void)setInlineIm:(BOOL)enable;
- (BOOL)inlineIm;
- (void)checkImState; - (void)checkImState;
@end @end
+11 -11
View File
@@ -213,6 +213,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
// called the input manager expects the marked text to be unmarked // called the input manager expects the marked text to be unmarked
// automatically, hence the explicit unmarkText: call here. // automatically, hence the explicit unmarkText: call here.
[self unmarkText]; [self unmarkText];
[textView clearMarkedText];
} }
// NOTE: 'string' is either an NSString or an NSAttributedString. Since we // NOTE: 'string' is either an NSString or an NSAttributedString. Since we
@@ -317,6 +318,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
// marked text moves outside the view as a result of scrolling. // marked text moves outside the view as a result of scrolling.
[self sendMarkedText:nil position:0]; [self sendMarkedText:nil position:0];
[self unmarkText]; [self unmarkText];
[textView clearMarkedText];
[[NSTextInputContext currentInputContext] discardMarkedText]; [[NSTextInputContext currentInputContext] discardMarkedText];
} }
@@ -616,7 +618,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
ASLogDebug(@"text='%@' range=%@", text, NSStringFromRange(range)); ASLogDebug(@"text='%@' range=%@", text, NSStringFromRange(range));
[self unmarkText]; [self unmarkText];
if ([self useInlineIm]) { if (inlineIm) {
if ([text isKindOfClass:[NSAttributedString class]]) if ([text isKindOfClass:[NSAttributedString class]])
text = [text string]; text = [text string];
@@ -629,7 +631,6 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
return; return;
} }
#ifdef INCLUDE_OLD_IM_CODE
if (!(text && [text length] > 0)) if (!(text && [text length] > 0))
return; return;
@@ -669,7 +670,6 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
} }
[textView setNeedsDisplay:YES]; [textView setNeedsDisplay:YES];
#endif // INCLUDE_OLD_IM_CODE
} }
- (void)unmarkText - (void)unmarkText
@@ -813,14 +813,14 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
} }
} }
- (BOOL)useInlineIm - (void)setInlineIm:(BOOL)enable
{ {
#ifdef INCLUDE_OLD_IM_CODE inlineIm = enable;
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; }
return [ud boolForKey:MMUseInlineImKey];
#else - (BOOL)inlineIm
return YES; {
#endif // INCLUDE_OLD_IM_CODE return inlineIm;
} }
- (void)checkImState - (void)checkImState
@@ -1064,7 +1064,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
- (void)sendMarkedText:(NSString *)text position:(int32_t)pos - (void)sendMarkedText:(NSString *)text position:(int32_t)pos
{ {
if (![self useInlineIm]) if (!inlineIm)
return; return;
NSMutableData *data = [NSMutableData data]; NSMutableData *data = [NSMutableData data];
+4
View File
@@ -833,6 +833,10 @@ static BOOL isUnsafeMessage(int msgid);
[[[windowController vimView] textView] activateIm:YES]; [[[windowController vimView] textView] activateIm:YES];
} else if (DeactivateKeyScriptMsgID == msgid) { } else if (DeactivateKeyScriptMsgID == msgid) {
[[[windowController vimView] textView] activateIm:NO]; [[[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) { } else if (EnableImControlMsgID == msgid) {
[[[windowController vimView] textView] setImControl:YES]; [[[windowController vimView] textView] setImControl:YES];
} else if (DisableImControlMsgID == msgid) { } else if (DisableImControlMsgID == msgid) {
+3
View File
@@ -251,6 +251,9 @@ enum {
DisableLigaturesMsgID, DisableLigaturesMsgID,
EnableThinStrokesMsgID, EnableThinStrokesMsgID,
DisableThinStrokesMsgID, DisableThinStrokesMsgID,
EnableInlineImMsgID,
DisableInlineImMsgID,
RedrawBlockMsgID,
LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM! LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM!
}; };
+3
View File
@@ -105,6 +105,9 @@ char *MessageStrings[] =
"DisableLigaturesMsgID", "DisableLigaturesMsgID",
"EnableThinStrokesMsgID", "EnableThinStrokesMsgID",
"DisableThinStrokesMsgID", "DisableThinStrokesMsgID",
"EnableInlineImMsgID",
"DisableInlineImMsgID",
"RedrawBlockMsgID",
"END OF MESSAGE IDs" // NOTE: Must be last! "END OF MESSAGE IDs" // NOTE: Must be last!
}; };
-7
View File
@@ -13,10 +13,6 @@
#import "MacVim.h" #import "MacVim.h"
// TODO: Remove this when the inline IM code has been tested
#define INCLUDE_OLD_IM_CODE
// NSUserDefaults keys // NSUserDefaults keys
extern NSString *MMTabMinWidthKey; extern NSString *MMTabMinWidthKey;
extern NSString *MMTabMaxWidthKey; extern NSString *MMTabMaxWidthKey;
@@ -45,9 +41,6 @@ extern NSString *MMOpenLayoutKey;
extern NSString *MMVerticalSplitKey; extern NSString *MMVerticalSplitKey;
extern NSString *MMPreloadCacheSizeKey; extern NSString *MMPreloadCacheSizeKey;
extern NSString *MMLastWindowClosedBehaviorKey; extern NSString *MMLastWindowClosedBehaviorKey;
#ifdef INCLUDE_OLD_IM_CODE
extern NSString *MMUseInlineImKey;
#endif // INCLUDE_OLD_IM_CODE
extern NSString *MMSuppressTerminationAlertKey; extern NSString *MMSuppressTerminationAlertKey;
extern NSString *MMNativeFullScreenKey; extern NSString *MMNativeFullScreenKey;
extern NSString *MMUseMouseTimeKey; extern NSString *MMUseMouseTimeKey;
-3
View File
@@ -41,9 +41,6 @@ NSString *MMOpenLayoutKey = @"MMOpenLayout";
NSString *MMVerticalSplitKey = @"MMVerticalSplit"; NSString *MMVerticalSplitKey = @"MMVerticalSplit";
NSString *MMPreloadCacheSizeKey = @"MMPreloadCacheSize"; NSString *MMPreloadCacheSizeKey = @"MMPreloadCacheSize";
NSString *MMLastWindowClosedBehaviorKey = @"MMLastWindowClosedBehavior"; NSString *MMLastWindowClosedBehaviorKey = @"MMLastWindowClosedBehavior";
#ifdef INCLUDE_OLD_IM_CODE
NSString *MMUseInlineImKey = @"MMUseInlineIm";
#endif // INCLUDE_OLD_IM_CODE
NSString *MMSuppressTerminationAlertKey = @"MMSuppressTerminationAlert"; NSString *MMSuppressTerminationAlertKey = @"MMSuppressTerminationAlert";
NSString *MMNativeFullScreenKey = @"MMNativeFullScreen"; NSString *MMNativeFullScreenKey = @"MMNativeFullScreen";
NSString *MMUseMouseTimeKey = @"MMUseMouseTime"; NSString *MMUseMouseTimeKey = @"MMUseMouseTime";
+11
View File
@@ -264,6 +264,8 @@ gui_mch_init(void)
gui_mch_adjust_charheight(); gui_mch_adjust_charheight();
gui_mch_adjust_charwidth(); gui_mch_adjust_charwidth();
gui_macvim_set_imstyle(p_imst);
if (!MMNoMRU && GARGCOUNT > 0) { if (!MMNoMRU && GARGCOUNT > 0) {
// Add files passed on command line to MRU. // Add files passed on command line to MRU.
NSMutableArray *filenames = [NSMutableArray array]; 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 ------------------------------------------------- // -- 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) if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT)
errmsg = e_invarg; errmsg = e_invarg;
# ifdef FEAT_GUI_MACVIM
gui_macvim_set_imstyle(p_imst);
# endif
} }
#endif #endif
+2
View File
@@ -235,6 +235,8 @@ gui_mch_find_dialog(exarg_T *eap);
gui_mch_replace_dialog(exarg_T *eap); gui_mch_replace_dialog(exarg_T *eap);
void void
im_set_control(int enable); im_set_control(int enable);
void
gui_macvim_set_imstyle(long imstyle);
void * void *
gui_macvim_add_channel(channel_T *channel, ch_part_T part); gui_macvim_add_channel(channel_T *channel, ch_part_T part);