diff --git a/macos/Ghostty.xcodeproj/project.pbxproj b/macos/Ghostty.xcodeproj/project.pbxproj index 153b146a9..7c67ecf90 100644 --- a/macos/Ghostty.xcodeproj/project.pbxproj +++ b/macos/Ghostty.xcodeproj/project.pbxproj @@ -40,6 +40,9 @@ A5CEAFDC29B8009000646FDA /* SplitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5CEAFDB29B8009000646FDA /* SplitView.swift */; }; A5CEAFDE29B8058B00646FDA /* SplitView.Divider.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5CEAFDD29B8058B00646FDA /* SplitView.Divider.swift */; }; A5CEAFFF29C2410700646FDA /* Backport.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5CEAFFE29C2410700646FDA /* Backport.swift */; }; + A5E112932AF73E6E00C6E0C2 /* PasteProtection.xib in Resources */ = {isa = PBXBuildFile; fileRef = A5E112922AF73E6E00C6E0C2 /* PasteProtection.xib */; }; + A5E112952AF73E8A00C6E0C2 /* PasteProtectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E112942AF73E8A00C6E0C2 /* PasteProtectionController.swift */; }; + A5E112972AF7401B00C6E0C2 /* PasteProtectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E112962AF7401B00C6E0C2 /* PasteProtectionView.swift */; }; A5FEB3002ABB69450068369E /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FEB2FF2ABB69450068369E /* main.swift */; }; /* End PBXBuildFile section */ @@ -80,6 +83,9 @@ A5CEAFDD29B8058B00646FDA /* SplitView.Divider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitView.Divider.swift; sourceTree = ""; }; A5CEAFFE29C2410700646FDA /* Backport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Backport.swift; sourceTree = ""; }; A5D495A1299BEC7E00DD1313 /* GhosttyKit.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = GhosttyKit.xcframework; sourceTree = ""; }; + A5E112922AF73E6E00C6E0C2 /* PasteProtection.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PasteProtection.xib; sourceTree = ""; }; + A5E112942AF73E8A00C6E0C2 /* PasteProtectionController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasteProtectionController.swift; sourceTree = ""; }; + A5E112962AF7401B00C6E0C2 /* PasteProtectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasteProtectionView.swift; sourceTree = ""; }; A5FEB2FF2ABB69450068369E /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -101,6 +107,7 @@ children = ( A56D58872ACDE6BE00508D2C /* Services */, A59630982AEE1C4400D64628 /* Terminal */, + A5E112912AF73E4D00C6E0C2 /* Paste Protection */, A534263E2A7DCC5800EBB7A2 /* Settings */, ); path = Features; @@ -227,6 +234,16 @@ name = Frameworks; sourceTree = ""; }; + A5E112912AF73E4D00C6E0C2 /* Paste Protection */ = { + isa = PBXGroup; + children = ( + A5E112922AF73E6E00C6E0C2 /* PasteProtection.xib */, + A5E112942AF73E8A00C6E0C2 /* PasteProtectionController.swift */, + A5E112962AF7401B00C6E0C2 /* PasteProtectionView.swift */, + ); + path = "Paste Protection"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -289,6 +306,7 @@ A596309A2AEE1C6400D64628 /* Terminal.xib in Resources */, A5A1F8852A489D6800D1E8BC /* terminfo in Resources */, A5CDF1912AAF9A5800513312 /* ConfigurationErrors.xib in Resources */, + A5E112932AF73E6E00C6E0C2 /* PasteProtection.xib in Resources */, A5B30539299BEAAB0047F10C /* Assets.xcassets in Resources */, 857F63812A5E64F200CA4815 /* MainMenu.xib in Resources */, ); @@ -324,9 +342,11 @@ A55685E029A03A9F004303CE /* AppError.swift in Sources */, A535B9DA299C569B0017E2E4 /* ErrorView.swift in Sources */, A5CEAFFF29C2410700646FDA /* Backport.swift in Sources */, + A5E112952AF73E8A00C6E0C2 /* PasteProtectionController.swift in Sources */, 8503D7C72A549C66006CFF3D /* FullScreenHandler.swift in Sources */, A596309E2AEE1D6C00D64628 /* TerminalView.swift in Sources */, A5CEAFDE29B8058B00646FDA /* SplitView.Divider.swift in Sources */, + A5E112972AF7401B00C6E0C2 /* PasteProtectionView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/macos/Sources/Features/Paste Protection/PasteProtection.xib b/macos/Sources/Features/Paste Protection/PasteProtection.xib new file mode 100644 index 000000000..312a3da5a --- /dev/null +++ b/macos/Sources/Features/Paste Protection/PasteProtection.xib @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macos/Sources/Features/Paste Protection/PasteProtectionController.swift b/macos/Sources/Features/Paste Protection/PasteProtectionController.swift new file mode 100644 index 000000000..bad16bf06 --- /dev/null +++ b/macos/Sources/Features/Paste Protection/PasteProtectionController.swift @@ -0,0 +1,15 @@ +import Foundation +import Cocoa +import SwiftUI +import GhosttyKit + +class PasteProtectionController: NSWindowController { + override var windowNibName: NSNib.Name? { "PasteProtection" } + + //MARK: - NSWindowController + + override func windowDidLoad() { + guard let window = window else { return } + window.contentView = NSHostingView(rootView: PasteProtectionView()) + } +} diff --git a/macos/Sources/Features/Paste Protection/PasteProtectionView.swift b/macos/Sources/Features/Paste Protection/PasteProtectionView.swift new file mode 100644 index 000000000..61d084cbe --- /dev/null +++ b/macos/Sources/Features/Paste Protection/PasteProtectionView.swift @@ -0,0 +1,18 @@ +import SwiftUI + +struct PasteProtectionView: View { + var body: some View { + HStack { + Image("AppIconImage") + .resizable() + .scaledToFit() + .frame(width: 128, height: 128) + + VStack(alignment: .leading) { + Text("Oh, no. 😭").font(.title) + Text("Something went fatally wrong.\nCheck the logs and restart Ghostty.") + } + } + .padding() + } +} diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 66fe9c965..7aa4b7b26 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -115,6 +115,10 @@ class TerminalController: NSWindowController, NSWindowDelegate, TerminalViewDele viewModel: self, delegate: self )) + + // TODO: remove this, just for dev + let pp = PasteProtectionController() + window.beginSheet(pp.window!) } // Shows the "+" button in the tab bar, responds to that click.