From 6025ea6cc2acbc5f12a1655eefa875e90f576847 Mon Sep 17 00:00:00 2001 From: Noah Fetz Date: Thu, 20 May 2021 16:00:24 +0200 Subject: [PATCH] Add ability to copy the console content to the clipboard --- Sources/LocalConsole/LCManager.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/LocalConsole/LCManager.swift b/Sources/LocalConsole/LCManager.swift index a71fbb0..9e01cca 100644 --- a/Sources/LocalConsole/LCManager.swift +++ b/Sources/LocalConsole/LCManager.swift @@ -205,6 +205,11 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate { consoleTextView.text = "" } + /// Copy the console view text to the device's clipboard + public func copyToClipboard() { + UIPasteboard.general.string = consoleTextView.text + } + // MARK: - Private private var debugBordersEnabled = false { @@ -305,7 +310,12 @@ public class LCManager: NSObject, UIGestureRecognizerDelegate { self.clear() }) - return UIMenu(title: "", children: [primarySection, clear]) + let copyToClipboard = UIAction(title: "Copy to clipboard", + image: UIImage(systemName: "paperclip"), handler: { _ in + self.copyToClipboard() + }) + + return UIMenu(title: "", children: [primarySection, clear, copyToClipboard]) } @objc func longPressAction(recognizer: UILongPressGestureRecognizer) {