1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-01 18:39:52 +03:00
vimr/SwiftNeoVim/CocoaExtensions.swift

40 lines
775 B
Swift
Raw Normal View History

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
2016-06-16 19:36:26 +03:00
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] {
2016-09-25 18:50:33 +03:00
var rectsPtr: UnsafePointer<CGRect>? = nil
var count: Int = 0
self.getRectsBeingDrawn(&rectsPtr, count: &count)
return Array(UnsafeBufferPointer(start: rectsPtr, count: count))
}
2016-06-16 19:36:26 +03:00
}