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:
Bjorn Winckler
2008-02-11 20:52:48 +01:00
parent ddfeb8cac3
commit 1f5a9fa89b
3 changed files with 20 additions and 1 deletions
+5
View File
@@ -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];
}
+13
View File
@@ -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
View File
@@ -171,7 +171,8 @@ enum {
DeleteLinesDrawType,
DrawStringDrawType,
InsertLinesDrawType,
DrawCursorDrawType
DrawCursorDrawType,
SetCursorPosDrawType,
};
enum {