From 6661f41deba70ec0e740860f785a8d12de6ca7e1 Mon Sep 17 00:00:00 2001 From: TZGyn Date: Tue, 27 Oct 2026 21:36:28 +0800 Subject: [PATCH] Add Copy & Delete to the selection bar Scissors icon next to the copy actions; a single item copies as-is (image included), a multi-selection copies as plain lines, then everything selected is deleted. --- AGENTS.md | 3 ++- Sources/Prompt/PanelView.swift | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index aede21c..866a437 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -58,7 +58,8 @@ clicking an item copies it back to the clipboard. There is no in-header close button: the window's own close button hides the panel. Composer `# Name` creates/ switches sections. Click = select (Shift+click for a range); the selection - bar offers Copy (single item), Copy as List, Copy as Lines and Delete; + bar offers Copy (single item), Copy as List, Copy as Lines, Copy & Delete + (scissors icon) and Delete; right-click = context menu acting on the whole selection (Copy, Copy as List, Copy as Lines, Copy & Delete, Done, Edit, Open, Merge, Move To, Delete). Esc clears the selection before it hides the panel. Selection is scoped to the current view: diff --git a/Sources/Prompt/PanelView.swift b/Sources/Prompt/PanelView.swift index 04aed89..5c69b47 100644 --- a/Sources/Prompt/PanelView.swift +++ b/Sources/Prompt/PanelView.swift @@ -705,6 +705,12 @@ struct PanelView: View { .font(.caption) .buttonStyle(.plain) .foregroundStyle(Color.accentColor) + Button { copyAndDeleteSelection() } label: { + Image(systemName: "scissors") + } + .buttonStyle(.plain) + .foregroundStyle(Color.accentColor) + .help("Copy & Delete") Button { deleteSelection() } label: { Image(systemName: "trash") } @@ -729,6 +735,20 @@ struct PanelView: View { clearSelection() } + /// Same as the context menu's Copy & Delete, for the selection bar. A + /// single image still copies as an image; a multi-selection copies as + /// plain lines, same as Copy as Lines. + private func copyAndDeleteSelection() { + guard !selection.isEmpty else { return } + if selection.count == 1, let id = selection.first, let item = store.item(id) { + store.copy(item) + } else { + store.copyAsLines(ids: selection) + } + store.delete(ids: selection) + clearSelection() + } + private func copySelection(asList: Bool) { guard !selection.isEmpty else { return } if asList {