mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-05-20 23:28:39 +03:00
38 lines
1.2 KiB
Swift
38 lines
1.2 KiB
Swift
import Foundation
|
|
import Cocoa
|
|
import SwiftUI
|
|
import GhosttyKit
|
|
|
|
/// This initializes an "unsafe paste" warning window. The window itself WILL NOT show automatically
|
|
/// and the caller must show the window via showWindow, beginSheet, etc.
|
|
class PasteProtectionController: NSWindowController {
|
|
override var windowNibName: NSNib.Name? { "PasteProtection" }
|
|
|
|
let surface: ghostty_surface_t
|
|
let contents: String
|
|
let state: UnsafeMutableRawPointer?
|
|
weak private var delegate: PasteProtectionViewDelegate? = nil
|
|
|
|
init(surface: ghostty_surface_t, contents: String, state: UnsafeMutableRawPointer?, delegate: PasteProtectionViewDelegate) {
|
|
self.surface = surface
|
|
self.contents = contents
|
|
self.state = state
|
|
self.delegate = delegate
|
|
super.init(window: nil)
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) is not supported for this view")
|
|
}
|
|
|
|
//MARK: - NSWindowController
|
|
|
|
override func windowDidLoad() {
|
|
guard let window = window else { return }
|
|
window.contentView = NSHostingView(rootView: PasteProtectionView(
|
|
contents: contents,
|
|
delegate: delegate
|
|
))
|
|
}
|
|
}
|