-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Enable macOS Services menu on terminal right-click #2699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11707,6 +11707,59 @@ extension GhosttyNSView: NSTextInputClient { | |||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // MARK: - Services | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| extension GhosttyNSView: NSServicesMenuRequestor { | ||||||||||||||||||||||||||||||||||||||||||||||
| override func validRequestor( | ||||||||||||||||||||||||||||||||||||||||||||||
| forSendType sendType: NSPasteboard.PasteboardType?, | ||||||||||||||||||||||||||||||||||||||||||||||
| returnType: NSPasteboard.PasteboardType? | ||||||||||||||||||||||||||||||||||||||||||||||
| ) -> Any? { | ||||||||||||||||||||||||||||||||||||||||||||||
| let supportedTypes: [NSPasteboard.PasteboardType] = [ | ||||||||||||||||||||||||||||||||||||||||||||||
| .string, | ||||||||||||||||||||||||||||||||||||||||||||||
| .init("public.utf8-plain-text") | ||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if (returnType == nil || supportedTypes.contains(returnType!)) && | ||||||||||||||||||||||||||||||||||||||||||||||
| (sendType == nil || supportedTypes.contains(sendType!)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| if let sendType, supportedTypes.contains(sendType) { | ||||||||||||||||||||||||||||||||||||||||||||||
| guard let surface, ghostty_surface_has_selection(surface) else { | ||||||||||||||||||||||||||||||||||||||||||||||
| return super.validRequestor(forSendType: sendType, returnType: returnType) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+11722
to
+11728
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| return self | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| return super.validRequestor(forSendType: sendType, returnType: returnType) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| func writeSelection( | ||||||||||||||||||||||||||||||||||||||||||||||
| to pboard: NSPasteboard, | ||||||||||||||||||||||||||||||||||||||||||||||
| types: [NSPasteboard.PasteboardType] | ||||||||||||||||||||||||||||||||||||||||||||||
| ) -> Bool { | ||||||||||||||||||||||||||||||||||||||||||||||
| guard let snapshot = readSelectionSnapshot() else { return false } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| pboard.declareTypes([.string], owner: nil) | ||||||||||||||||||||||||||||||||||||||||||||||
| pboard.setString(snapshot.string, forType: .string) | ||||||||||||||||||||||||||||||||||||||||||||||
| return true | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+11736
to
+11745
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| func readSelection(from pboard: NSPasteboard) -> Bool { | ||||||||||||||||||||||||||||||||||||||||||||||
| guard ensureSurfaceReadyForInput() != nil else { return false } | ||||||||||||||||||||||||||||||||||||||||||||||
| guard let string = GhosttyPasteboardHelper.stringContents(from: pboard) else { return false } | ||||||||||||||||||||||||||||||||||||||||||||||
| guard !string.isEmpty else { return true } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // Services can return multiline payloads. Route them through the text/paste path | ||||||||||||||||||||||||||||||||||||||||||||||
| // so Ghostty handles them as pasted text instead of synthesizing Return/Tab keys. | ||||||||||||||||||||||||||||||||||||||||||||||
| if let terminalSurface { | ||||||||||||||||||||||||||||||||||||||||||||||
| terminalSurface.sendText(string) | ||||||||||||||||||||||||||||||||||||||||||||||
| return true | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| return false | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // MARK: - SwiftUI Wrapper | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| struct GhosttyTerminalView: NSViewRepresentable { | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| +11 −8 | Sources/Bonsplit/Internal/Views/SplitContainerView.swift | |
| +39 −2 | Sources/Bonsplit/Internal/Views/SplitNodeView.swift | |
| +50 −22 | Sources/Bonsplit/Internal/Views/TabBarView.swift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate entries in supported pasteboard types array
Low Severity
NSPasteboard.PasteboardType.stringhas the raw value"public.utf8-plain-text", so.stringand.init("public.utf8-plain-text")are the same type. ThesupportedTypesarray contains two identical entries. If the intent was to also cover the legacy Objective-C"NSStringPboardType"pasteboard type, the wrong string was used. The codebase already defines a constant for this atGhosttyPasteboardHelper.utf8PlainTextType.Reviewed by Cursor Bugbot for commit 3340e71. Configure here.