1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 11:37:32 +03:00
vimr/SwiftNeoVim/CocoaExtensions.swift
2016-09-25 17:50:33 +02:00

40 lines
775 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))
}
}