mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Send cursor position on each batch draw
The cursor position is used to set the selected range in the MMTextView. This provides some support for voice over (enable with Mac+F5).
This commit is contained in:
@@ -441,6 +441,11 @@ static NSString *MMSymlinkWarningString =
|
||||
[self setWideFont:oldWideFont];
|
||||
}
|
||||
|
||||
int type = SetCursorPosDrawType;
|
||||
[drawData appendBytes:&type length:sizeof(type)];
|
||||
[drawData appendBytes:&gui.row length:sizeof(gui.row)];
|
||||
[drawData appendBytes:&gui.col length:sizeof(gui.col)];
|
||||
|
||||
[self queueMessage:BatchDrawMsgID data:[drawData copy]];
|
||||
[drawData setLength:0];
|
||||
}
|
||||
|
||||
@@ -195,6 +195,7 @@ enum {
|
||||
|
||||
const void *bytes = [data bytes];
|
||||
const void *end = bytes + [data length];
|
||||
int cursorRow = -1, cursorCol = 0;
|
||||
|
||||
#if MM_DEBUG_DRAWING
|
||||
NSLog(@"====> BEGIN %s", _cmd);
|
||||
@@ -304,6 +305,9 @@ enum {
|
||||
[self drawInsertionPointAtRow:row column:col shape:shape
|
||||
fraction:percent
|
||||
color:[NSColor colorWithRgbInt:color]];
|
||||
} else if (SetCursorPosDrawType == type) {
|
||||
cursorRow = *((int*)bytes); bytes += sizeof(int);
|
||||
cursorCol = *((int*)bytes); bytes += sizeof(int);
|
||||
} else {
|
||||
NSLog(@"WARNING: Unknown draw type (type=%d)", type);
|
||||
}
|
||||
@@ -311,6 +315,15 @@ enum {
|
||||
|
||||
[textStorage endEditing];
|
||||
|
||||
if (cursorRow >= 0) {
|
||||
unsigned off = [textStorage characterIndexForRow:cursorRow
|
||||
column:cursorCol];
|
||||
unsigned maxoff = [[textStorage string] length];
|
||||
if (off > maxoff) off = maxoff;
|
||||
|
||||
[self setSelectedRange:NSMakeRange(off, 0)];
|
||||
}
|
||||
|
||||
// NOTE: During resizing, Cocoa only sends draw messages before Vim's rows
|
||||
// and columns are changed (due to ipc delays). Force a redraw here.
|
||||
[self displayIfNeeded];
|
||||
|
||||
+2
-1
@@ -171,7 +171,8 @@ enum {
|
||||
DeleteLinesDrawType,
|
||||
DrawStringDrawType,
|
||||
InsertLinesDrawType,
|
||||
DrawCursorDrawType
|
||||
DrawCursorDrawType,
|
||||
SetCursorPosDrawType,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
||||
Reference in New Issue
Block a user