From d89588736151abaa7608ff0b1cc7ec9aae25c8e8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 5 Aug 2023 14:50:18 -0700 Subject: [PATCH] macos: enable copy/paste menu items in "Edit" --- macos/Sources/Ghostty/SurfaceView.swift | 17 +++++++++++++++++ macos/Sources/MainMenu.xib | 24 ++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/macos/Sources/Ghostty/SurfaceView.swift b/macos/Sources/Ghostty/SurfaceView.swift index 81a7bca81..2bb9c5e8d 100644 --- a/macos/Sources/Ghostty/SurfaceView.swift +++ b/macos/Sources/Ghostty/SurfaceView.swift @@ -381,6 +381,23 @@ extension Ghostty { ghostty_surface_key(surface, action, key, unmapped_key, mods) } + // MARK: Menu Handlers + + @IBAction func copy(_ sender: Any?) { + guard let surface = self.surface else { return } + ghostty_surface_binding_action(surface, GHOSTTY_BINDING_COPY_TO_CLIPBOARD, nil) + } + + @IBAction func paste(_ sender: Any?) { + guard let surface = self.surface else { return } + ghostty_surface_binding_action(surface, GHOSTTY_BINDING_PASTE_FROM_CLIPBOARD, nil) + } + + @IBAction func pasteAsPlainText(_ sender: Any?) { + guard let surface = self.surface else { return } + ghostty_surface_binding_action(surface, GHOSTTY_BINDING_PASTE_FROM_CLIPBOARD, nil) + } + // MARK: NSTextInputClient func hasMarkedText() -> Bool { diff --git a/macos/Sources/MainMenu.xib b/macos/Sources/MainMenu.xib index 04481f332..da8332a4f 100644 --- a/macos/Sources/MainMenu.xib +++ b/macos/Sources/MainMenu.xib @@ -94,9 +94,29 @@ - + - + + + + + + + + + + + + + + + + + + + + +