mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-09-14 18:01:58 +00:00
15 lines
410 B
Swift
15 lines
410 B
Swift
import AppKit
|
|
|
|
extension Ghostty.SurfaceView {
|
|
/// A snapshot image of the current surface view.
|
|
var asImage: NSImage? {
|
|
guard let bitmapRep = bitmapImageRepForCachingDisplay(in: bounds) else {
|
|
return nil
|
|
}
|
|
cacheDisplay(in: bounds, to: bitmapRep)
|
|
let image = NSImage(size: bounds.size)
|
|
image.addRepresentation(bitmapRep)
|
|
return image
|
|
}
|
|
}
|