1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-27 15:53:31 +03:00
vimr/SwiftNeoVim/CocoaExtensions.swift
2016-06-27 18:42:35 +02:00

40 lines
774 B
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
extension CGRect {
func fill() {
NSRectFill(self)
}
}
extension NSRange: CustomStringConvertible {
public var description: String {
var location = ""
if self.location == NSNotFound {
location = "NotFound"
} else {
location = String(self.location)
}
return "NSRange<\(location), \(self.length)>"
}
}
extension NSView {
/// - Returns: Rects currently being drawn
/// - Warning: Call only in drawRect()
func rectsBeingDrawn() -> [CGRect] {
var rectsPtr: UnsafePointer<CGRect> = nil
var count: Int = 0
self.getRectsBeingDrawn(&rectsPtr, count: &count)
return Array(UnsafeBufferPointer(start: rectsPtr, count: count))
}
}