From 97cc6e4ad5761ed05a9a7ca2410c5d8cb6d20610 Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Mon, 11 Jul 2016 19:37:06 +0200 Subject: [PATCH] Make cursor drawing a bit better - we still have to overhaul the cursor drawing, this is just a temporary fix... --- SwiftNeoVim/NeoVimView.swift | 4 ++-- SwiftNeoVim/NeoVimViewUiBridge.swift | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/SwiftNeoVim/NeoVimView.swift b/SwiftNeoVim/NeoVimView.swift index 487df080..8f731d53 100644 --- a/SwiftNeoVim/NeoVimView.swift +++ b/SwiftNeoVim/NeoVimView.swift @@ -207,8 +207,8 @@ public class NeoVimView: NSView { private func drawCursor(background: UInt32) { // FIXME: for now do some rudimentary cursor drawing - let cursorPosition = self.grid.screenCursor -// Swift.print("\(#function): \(cursorPosition)") + let cursorPosition = self.grid.putPosition +// NSLog("\(#function): \(cursorPosition)") var cursorRect = self.cellRectFor(row: cursorPosition.row, column: cursorPosition.column) if self.grid.isNextCellEmpty(cursorPosition) { diff --git a/SwiftNeoVim/NeoVimViewUiBridge.swift b/SwiftNeoVim/NeoVimViewUiBridge.swift index c8238899..c0f1e536 100644 --- a/SwiftNeoVim/NeoVimViewUiBridge.swift +++ b/SwiftNeoVim/NeoVimViewUiBridge.swift @@ -46,8 +46,10 @@ extension NeoVimView: NeoVimUiBridgeProtocol { DispatchUtils.gui { // NSLog("\(#function): \(position), \(screenCursor)") - self.setNeedsDisplay(cellPosition: self.grid.screenCursor) // redraw where the cursor was till now - self.setNeedsDisplay(screenCursor: screenCursor) // draw the new cursor + // Because neovim fills blank space with "Space" and when we enter "Space" we don't get the puts. + self.setNeedsDisplay(cellPosition: self.grid.putPosition) + self.setNeedsDisplay(cellPosition: self.grid.nextCellPosition(self.grid.putPosition)) + self.setNeedsDisplay(screenCursor: position) self.grid.goto(position) self.grid.moveCursor(screenCursor) @@ -99,7 +101,9 @@ extension NeoVimView: NeoVimUiBridgeProtocol { // NSLog("\(#function): \(curPos) -> \(string)") self.grid.put(string) self.setNeedsDisplay(cellPosition: curPos) - + // When the cursor is in the command line, then we need this... + self.setNeedsDisplay(cellPosition: self.grid.nextCellPosition(curPos)) + self.setNeedsDisplay(screenCursor: self.grid.screenCursor) } } @@ -111,6 +115,8 @@ extension NeoVimView: NeoVimUiBridgeProtocol { self.grid.putMarkedText(markedText) self.setNeedsDisplay(position: curPos) + // When the cursor is in the command line, then we need this... + self.setNeedsDisplay(cellPosition: self.grid.nextCellPosition(curPos)) if markedText.characters.count == 0 { self.setNeedsDisplay(position: self.grid.previousCellPosition(curPos)) } @@ -141,7 +147,7 @@ extension NeoVimView: NeoVimUiBridgeProtocol { } public func flush() { -// Swift.print("\(self.grid)") +// NSLog("\(#function)") } public func updateForeground(fg: Int32) {