From c625b5319511549496f2241d4106acd8b33e0aed Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Fri, 8 Aug 2025 15:06:20 +0100 Subject: [PATCH] added a menu to copy scrollback, need to strip the excape sequances next made the snippet adder button always show --- ShhShell/Views/Snippets/SnippetPicker.swift | 13 +++++++----- ShhShell/Views/Terminal/ShellTabView.swift | 23 ++++++++++++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ShhShell/Views/Snippets/SnippetPicker.swift b/ShhShell/Views/Snippets/SnippetPicker.swift index ca98a44..4dc5472 100644 --- a/ShhShell/Views/Snippets/SnippetPicker.swift +++ b/ShhShell/Views/Snippets/SnippetPicker.swift @@ -22,11 +22,6 @@ struct SnippetPicker: View { Text("No Snippets") .font(.headline) .monospaced() - Button() { - showAdder.toggle() - } label: { - Label("Add", systemImage: "plus.circle.fill") - } } ForEach(hostsManager.snippets) { snip in Button(snip.name) { @@ -34,6 +29,14 @@ struct SnippetPicker: View { callback?(snip) } } + + Section { + Button() { + showAdder.toggle() + } label: { + Label("Add", systemImage: "plus.circle.fill") + } + } } .sheet(isPresented: $showAdder) { AddSnippetView(hostsManager: hostsManager) diff --git a/ShhShell/Views/Terminal/ShellTabView.swift b/ShhShell/Views/Terminal/ShellTabView.swift index ddf31e3..f97d32d 100644 --- a/ShhShell/Views/Terminal/ShellTabView.swift +++ b/ShhShell/Views/Terminal/ShellTabView.swift @@ -13,6 +13,9 @@ struct ShellTabView: View { @ObservedObject var container = TerminalViewContainer.shared @State var selectedID: UUID? + var selectedHandler: SSHHandler { + container.sessions[selectedID ?? UUID()]?.handler ?? handler! + } @State var showSnippetPicker: Bool = false @@ -63,13 +66,13 @@ struct ShellTabView: View { } Spacer() VStack { - Text(container.sessions[selectedID ?? UUID()]?.handler.title ?? handler?.title ?? "") + Text(selectedHandler.title) .bold() .foregroundStyle(foreground) .monospaced() .contentTransition(.numericText()) if container.sessionIDs.count == 1 { - Text(container.sessions[selectedID ?? UUID()]?.handler.host.description ?? handler?.host.description ?? "") + Text(selectedHandler.host.description) .bold() .foregroundStyle(foreground) .monospaced() @@ -87,10 +90,24 @@ struct ShellTabView: View { .foregroundStyle(foreground) .popover(isPresented: $showSnippetPicker) { SnippetPicker(hostsManager: hostsManager) { - container.sessions[selectedID ?? UUID()]?.handler.writeToChannel($0.content) + selectedHandler.writeToChannel($0.content) } + .frame(minWidth: 200, minHeight: 300) .modifier(presentationCompactPopover()) } + Menu { + Button() { + UIPasteboard.general.string = selectedHandler.scrollback.joined() + Haptic.success.trigger() + } label: { + Label("Copy Scrollback", systemImage: "document.on.document") + } + } label: { + Image(systemName: "ellipsis") + .resizable().scaledToFit() + .frame(width: 20, height: 20) + } + .foregroundStyle(foreground) } .padding(.horizontal, 10) .padding(.vertical, 10)