mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Draw markedText in MMCoreTextView if imstyle=1
This commit is contained in:
@@ -2092,6 +2092,8 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
[self setImState:NO];
|
||||
} else if (BackingPropertiesChangedMsgID == msgid) {
|
||||
[self redrawScreen];
|
||||
} else if (RedrawBlockMsgID == msgid) {
|
||||
[self handleRedrawBlock:data];
|
||||
} else {
|
||||
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
|
||||
- (void)bevalCallback:(id)sender
|
||||
{
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
int maxRows, maxColumns;
|
||||
NSColor *defaultBackgroundColor;
|
||||
NSColor *defaultForegroundColor;
|
||||
int defaultBackgroundHexColor;
|
||||
int defaultForegroundHexColor;
|
||||
NSSize cellSize;
|
||||
NSFont *font;
|
||||
NSFont *fontWide;
|
||||
@@ -51,6 +53,12 @@
|
||||
void *trackingRectUserData_;
|
||||
NSTrackingRectTag lastToolTipTag_;
|
||||
NSString* toolTip_;
|
||||
|
||||
NSUInteger markedRangeLength;
|
||||
int markedTextStartRow;
|
||||
int markedTextStartColumn;
|
||||
int markedTextEndRow;
|
||||
int markedTextEndColumn;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame;
|
||||
@@ -90,6 +98,7 @@
|
||||
- (void)setInlineIm:(BOOL)enable;
|
||||
- (void)activateIm:(BOOL)enable;
|
||||
- (void)checkImState;
|
||||
- (void)clearMarkedText;
|
||||
- (BOOL)convertPoint:(NSPoint)point toRow:(int *)row column:(int *)column;
|
||||
- (NSRect)rectForRow:(int)row column:(int)column numRows:(int)nr
|
||||
numColumns:(int)nc;
|
||||
|
||||
@@ -205,6 +205,13 @@ defaultAdvanceForFont(NSFont *font)
|
||||
if (defaultBackgroundColor != bgColor) {
|
||||
[defaultBackgroundColor release];
|
||||
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
|
||||
@@ -213,6 +220,13 @@ defaultAdvanceForFont(NSFont *font)
|
||||
if (defaultForegroundColor != fgColor) {
|
||||
[defaultForegroundColor release];
|
||||
defaultForegroundColor = fgColor ? [fgColor retain] : nil;
|
||||
if (fgColor) {
|
||||
defaultForegroundHexColor =
|
||||
(int)(fgColor.blueComponent * 0xff) |
|
||||
((int)(fgColor.greenComponent * 0xff) << 8) |
|
||||
((int)(fgColor.redComponent * 0xff) << 16) |
|
||||
(0xff << 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,6 +513,23 @@ defaultAdvanceForFont(NSFont *font)
|
||||
[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
|
||||
{
|
||||
[helper unmarkText];
|
||||
@@ -652,6 +683,40 @@ defaultAdvanceForFont(NSFont *font)
|
||||
|
||||
[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
|
||||
|
||||
@@ -75,4 +75,5 @@
|
||||
- (void)deleteSign:(NSString *)signName;
|
||||
- (void)setToolTipAtMousePoint:(NSString *)string;
|
||||
- (void)setCGLayerEnabled:(BOOL)enabled;
|
||||
- (void)clearMarkedText;
|
||||
@end
|
||||
|
||||
@@ -731,6 +731,10 @@
|
||||
[helper unmarkText];
|
||||
}
|
||||
|
||||
- (void)clearMarkedText
|
||||
{
|
||||
}
|
||||
|
||||
- (NSRect)firstRectForCharacterRange:(NSRange)range
|
||||
{
|
||||
return [helper firstRectForCharacterRange:range];
|
||||
|
||||
@@ -213,6 +213,7 @@ KeyboardInputSourcesEqual(TISInputSourceRef a, TISInputSourceRef b)
|
||||
// called the input manager expects the marked text to be unmarked
|
||||
// automatically, hence the explicit unmarkText: call here.
|
||||
[self unmarkText];
|
||||
[textView clearMarkedText];
|
||||
}
|
||||
|
||||
// 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.
|
||||
[self sendMarkedText:nil position:0];
|
||||
[self unmarkText];
|
||||
[textView clearMarkedText];
|
||||
[[NSTextInputContext currentInputContext] discardMarkedText];
|
||||
}
|
||||
|
||||
|
||||
@@ -253,6 +253,7 @@ enum {
|
||||
DisableThinStrokesMsgID,
|
||||
EnableInlineImMsgID,
|
||||
DisableInlineImMsgID,
|
||||
RedrawBlockMsgID,
|
||||
LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM!
|
||||
};
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ char *MessageStrings[] =
|
||||
"DisableThinStrokesMsgID",
|
||||
"EnableInlineImMsgID",
|
||||
"DisableInlineImMsgID",
|
||||
"RedrawBlockMsgID",
|
||||
"END OF MESSAGE IDs" // NOTE: Must be last!
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user