1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 16:56:40 +03:00

Mark rectToScroll - clipRect for update

This commit is contained in:
Tae Won Ha 2017-05-29 20:39:42 +02:00
parent 689fc8d0a3
commit 844449d8e7
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -120,10 +120,6 @@ extension NeoVimView {
let scaledClipRect = clipRect.scaling(scale)
let drawOrigin = CGPoint(x: 0, y: offset).scaling(scale)
self.bridgeLogger.debug("bounds: \(self.bounds)")
self.bridgeLogger.debug("offset: \(offset), rectToScroll: \(rectToScroll), " +
"clipRect: \(scaledClipRect), draw-at: \(drawOrigin)")
bufferCtx.saveGState()
defer { bufferCtx.restoreGState() }
@ -133,6 +129,18 @@ extension NeoVimView {
self.setNeedsDisplay(clipRect)
let rectToUpdate: CGRect
if count > 0 {
rectToUpdate = rectToScroll.divided(atDistance: offset, from: .minYEdge).slice
} else {
rectToUpdate = rectToScroll.divided(atDistance: abs(offset), from: .maxYEdge).slice
}
self.markForRender(rect: rectToUpdate)
self.bridgeLogger.debug("offset: \(offset), rectToScroll: \(rectToScroll), " +
"clipRect: \(scaledClipRect), draw-at: \(drawOrigin), " +
"rect-to-update: \(rectToUpdate)")
// Do not send msgs to agent -> neovim in the delegate method. It causes spinning
// when you're opening a file with existing swap file.
self.delegate?.scroll()
@ -422,6 +430,10 @@ extension NeoVimView {
self.rectsToUpdate.insert(self.bounds)
}
func markForRender(rect: CGRect) {
self.rectsToUpdate.insert(rect)
}
func markForRender(region: Region) {
// position could be out of range when the last put position of the grid is out of range
if region.left < 0 || region.right >= self.grid.size.width