added a menu to copy scrollback, need to strip the excape sequances next

made the snippet adder button always show
This commit is contained in:
neon443
2025-08-08 15:06:20 +01:00
parent bee12c8a39
commit c625b53195
2 changed files with 28 additions and 8 deletions

View File

@@ -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)

View File

@@ -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)