mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: register that we accept/send text types for services
This commit is contained in:
@ -109,9 +109,10 @@ class AppDelegate: NSObject,
|
||||
// Initial config loading
|
||||
configDidReload(ghostty)
|
||||
|
||||
// Register our service provider. This must happen after everything
|
||||
// else is initialized.
|
||||
// Register our service provider. This must happen after everything is initialized.
|
||||
NSApp.servicesProvider = ServiceProvider()
|
||||
|
||||
// This registers the Ghostty => Services menu to exist.
|
||||
NSApp.servicesMenu = menuServices
|
||||
|
||||
// Configure user notifications
|
||||
|
@ -953,3 +953,42 @@ extension Ghostty.SurfaceView: NSTextInputClient {
|
||||
print("SEL: \(selector)")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Services
|
||||
|
||||
// https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/SysServices/Articles/using.html
|
||||
extension Ghostty.SurfaceView: NSServicesMenuRequestor {
|
||||
override func validRequestor(
|
||||
forSendType sendType: NSPasteboard.PasteboardType?,
|
||||
returnType: NSPasteboard.PasteboardType?
|
||||
) -> Any? {
|
||||
// Types that we accept sent to us
|
||||
let accepted: [NSPasteboard.PasteboardType] = [.string, .init("public.utf8-plain-text")]
|
||||
|
||||
// We can always receive the accepted types
|
||||
if (returnType == nil || accepted.contains(returnType!)) {
|
||||
return self
|
||||
}
|
||||
|
||||
// If we have a selection we can send the accepted types too
|
||||
// TODO selection
|
||||
if (sendType == nil || accepted.contains(sendType!)) {
|
||||
return self
|
||||
}
|
||||
|
||||
return super.validRequestor(forSendType: sendType, returnType: returnType)
|
||||
}
|
||||
|
||||
func writeSelection(
|
||||
to pboard: NSPasteboard,
|
||||
types: [NSPasteboard.PasteboardType]
|
||||
) -> Bool {
|
||||
// TODO
|
||||
return false
|
||||
}
|
||||
|
||||
func readSelection(from pboard: NSPasteboard) -> Bool {
|
||||
// TODO
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user