1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 14:52:19 +03:00

GH-253 Improve cursor rendering

- Tried to minimize the background filling by only filling the cursor
  rects, but it did not work. Dunno why...
This commit is contained in:
Tae Won Ha 2016-08-16 21:52:36 +02:00
parent 6c9e6ff612
commit 0d6d804925
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 5 additions and 8 deletions

View File

@ -181,6 +181,7 @@ static void server_ui_cursor_goto(UI *ui __unused, int row, int col) {
_put_column = col;
int values[] = { row, col, screen_cursor_row(), screen_cursor_column() };
// ILOG("%d:%d - %d:%d", values[0], values[1], values[2], values[3]);
NSData *data = [[NSData alloc] initWithBytes:values length:(4 * sizeof(int))];
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSetPosition data:data];
[data release];

View File

@ -316,10 +316,10 @@ extension NeoVimView {
context: context)
}
self.drawCursor(self.grid.foreground)
self.drawCursor(color: self.grid.background)
}
private func drawCursor(foreground: UInt32) {
private func drawCursor(color color: UInt32) {
// FIXME: for now do some rudimentary cursor drawing
let cursorPosition = self.mode == .Cmdline ? self.grid.putPosition : self.grid.screenCursor
// NSLog("\(#function): \(cursorPosition)")
@ -330,15 +330,11 @@ extension NeoVimView {
cursorRect = cursorRect.union(self.cellRectFor(row: nextPosition.row, column:nextPosition.column))
}
ColorUtils.colorIgnoringAlpha(foreground).set()
ColorUtils.colorIgnoringAlpha(color).set()
NSRectFillUsingOperation(cursorRect, .CompositeDifference)
}
private func drawBackground(positions positions: [CGPoint], background: UInt32) {
if background == self.grid.background {
return
}
ColorUtils.colorIgnoringAlpha(background).set()
// NSColor(calibratedRed: CGFloat(drand48()), green: CGFloat(drand48()), blue: CGFloat(drand48()), alpha: 1.0).set()
let backgroundRect = CGRect(
@ -1018,7 +1014,7 @@ extension NeoVimView: NeoVimUiBridgeProtocol {
self.setNeedsDisplay(region: self.grid.regionOfWord(at: screenCursor))
} else {
self.setNeedsDisplay(cellPosition: self.grid.putPosition)
self.setNeedsDisplay(screenCursor: position)
self.setNeedsDisplay(screenCursor: screenCursor)
}
self.setNeedsDisplay(cellPosition: self.grid.nextCellPosition(self.grid.putPosition))