1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-28 08:13:17 +03:00

Don't do unnec' computation...

This commit is contained in:
Tae Won Ha 2017-06-05 16:10:24 +02:00
parent 5c713c8d97
commit f844d0c205
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
2 changed files with 7 additions and 10 deletions

View File

@ -51,11 +51,7 @@ extension NeoVimView {
// in some cases only the put(0, 0)-cells should be redrawn.
// => FIXME: probably we have to consider this also when drawing further down,
// ie when the range starts with '0'...
self.drawBackground(
positions: rowFrag.range.map { self.pointInView(forRow: rowFrag.row, column: $0) },
background: rowFrag.attrs.background,
in: context
)
self.drawBackground(rowRun: rowFrag, in: context)
let positions = rowFrag.range
// filter out the put(0, 0)s (after a wide character)
@ -130,20 +126,21 @@ extension NeoVimView {
self.shouldDrawCursor = false
}
fileprivate func drawBackground(positions: [CGPoint], background: Int, in context: CGContext) {
fileprivate func drawBackground(rowRun: RowRun, in context: CGContext) {
context.saveGState()
defer { context.restoreGState() }
context.setFillColor(ColorUtils.colorIgnoringAlpha(background).cgColor)
context.setFillColor(ColorUtils.colorIgnoringAlpha(rowRun.attrs.background).cgColor)
// To use random color use the following
// NSColor(calibratedRed: CGFloat(drand48()),
// green: CGFloat(drand48()),
// blue: CGFloat(drand48()),
// alpha: 1.0).set()
let firstCellOrigin = self.pointInView(forRow: rowRun.row, column: rowRun.range.lowerBound)
let backgroundRect = CGRect(
x: positions[0].x, y: positions[0].y,
width: CGFloat(positions.count) * self.cellSize.width, height: self.cellSize.height
x: firstCellOrigin.x, y: firstCellOrigin.y,
width: CGFloat(rowRun.range.count) * self.cellSize.width, height: self.cellSize.height
)
context.fill(backgroundRect)
}

View File

@ -149,7 +149,7 @@ public class NeoVimView: NSView,
let logger = FileLogger(as: NeoVimView.self, with: URL(fileURLWithPath: "/tmp/nvv.log"))
let bridgeLogger = FileLogger(as: NeoVimView.self,
with: URL(fileURLWithPath: "/tmp/nvv-bridge.log"),
shouldLogDebug: nil)
shouldLogDebug: false)
let agent: NeoVimAgent
let grid = Grid()