From d7aab6eaaaeb94288d2f9ba5386bd0f76e827f97 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Mon, 21 Jul 2025 20:57:02 +0100 Subject: [PATCH] add snippet link - has no way to add snips update duplicatetheme --- ShhShell.xcodeproj/project.pbxproj | 8 ++--- ShhShell/Host/HostsManager.swift | 3 +- ShhShell/Views/ContentView.swift | 6 +++- ShhShell/Views/Snippets/SnippetManager.swift | 20 ------------- .../Views/Snippets/SnippetManagerView.swift | 29 +++++++++++++++++++ 5 files changed, 40 insertions(+), 26 deletions(-) delete mode 100644 ShhShell/Views/Snippets/SnippetManager.swift create mode 100644 ShhShell/Views/Snippets/SnippetManagerView.swift diff --git a/ShhShell.xcodeproj/project.pbxproj b/ShhShell.xcodeproj/project.pbxproj index 5552c05..0ebb43c 100644 --- a/ShhShell.xcodeproj/project.pbxproj +++ b/ShhShell.xcodeproj/project.pbxproj @@ -30,7 +30,7 @@ A93143BE2DF4D0B300FCD5DB /* libpthread.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = A93143BD2DF4D0A700FCD5DB /* libpthread.tbd */; }; A93143C02DF61B3200FCD5DB /* Host.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93143BF2DF61B3200FCD5DB /* Host.swift */; }; A93143C62DF61FE300FCD5DB /* ViewModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93143C52DF61FE300FCD5DB /* ViewModifiers.swift */; }; - A93F283D2E2A5DCB0092B8D5 /* SnippetManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93F283C2E2A5DCB0092B8D5 /* SnippetManager.swift */; }; + A93F283D2E2A5DCB0092B8D5 /* SnippetManagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93F283C2E2A5DCB0092B8D5 /* SnippetManagerView.swift */; }; A93F28412E2A5EEA0092B8D5 /* Snippet.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93F28402E2A5EEA0092B8D5 /* Snippet.swift */; }; A9485C712E1AECD000209824 /* JetBrainsMonoNerdFontMono-Italic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A9485C702E1AECD000209824 /* JetBrainsMonoNerdFontMono-Italic.ttf */; }; A9485C722E1AECD000209824 /* JetBrainsMonoNerdFontMono-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A9485C6E2E1AECD000209824 /* JetBrainsMonoNerdFontMono-Bold.ttf */; }; @@ -155,7 +155,7 @@ A93143BF2DF61B3200FCD5DB /* Host.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Host.swift; sourceTree = ""; }; A93143C22DF61F5700FCD5DB /* ShhShell.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ShhShell.entitlements; sourceTree = ""; }; A93143C52DF61FE300FCD5DB /* ViewModifiers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModifiers.swift; sourceTree = ""; }; - A93F283C2E2A5DCB0092B8D5 /* SnippetManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnippetManager.swift; sourceTree = ""; }; + A93F283C2E2A5DCB0092B8D5 /* SnippetManagerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnippetManagerView.swift; sourceTree = ""; }; A93F28402E2A5EEA0092B8D5 /* Snippet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Snippet.swift; sourceTree = ""; }; A9485C6E2E1AECD000209824 /* JetBrainsMonoNerdFontMono-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "JetBrainsMonoNerdFontMono-Bold.ttf"; sourceTree = ""; }; A9485C6F2E1AECD000209824 /* JetBrainsMonoNerdFontMono-BoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "JetBrainsMonoNerdFontMono-BoldItalic.ttf"; sourceTree = ""; }; @@ -439,7 +439,7 @@ A93F283E2E2A5DDE0092B8D5 /* Snippets */ = { isa = PBXGroup; children = ( - A93F283C2E2A5DCB0092B8D5 /* SnippetManager.swift */, + A93F283C2E2A5DCB0092B8D5 /* SnippetManagerView.swift */, ); path = Snippets; sourceTree = ""; @@ -779,7 +779,7 @@ A9FD37592E143D74005319A8 /* GenericPasswordConvertible.swift in Sources */, A9485C762E1AF59F00209824 /* FontManagerView.swift in Sources */, A98554592E0553AA009051BD /* KeyManager.swift in Sources */, - A93F283D2E2A5DCB0092B8D5 /* SnippetManager.swift in Sources */, + A93F283D2E2A5DCB0092B8D5 /* SnippetManagerView.swift in Sources */, A9C897EF2DF1A9A400EF9A5F /* SSHHandler.swift in Sources */, A9D819312E102D8700442D38 /* HostkeysView.swift in Sources */, A98554552E05535F009051BD /* KeyManagerView.swift in Sources */, diff --git a/ShhShell/Host/HostsManager.swift b/ShhShell/Host/HostsManager.swift index f345493..6ae3b43 100644 --- a/ShhShell/Host/HostsManager.swift +++ b/ShhShell/Host/HostsManager.swift @@ -144,8 +144,9 @@ class HostsManager: ObservableObject, @unchecked Sendable { func duplicateTheme(_ theme: Theme) { var newTheme = theme newTheme.id = UUID().uuidString + newTheme.name.append(" copy") if let index = themes.firstIndex(where: { $0.id == theme.id }) { - themes.insert(newTheme, at: index) + themes.insert(newTheme, at: index+1) } else { themes.append(newTheme) } diff --git a/ShhShell/Views/ContentView.swift b/ShhShell/Views/ContentView.swift index d39cead..d7dbe2e 100644 --- a/ShhShell/Views/ContentView.swift +++ b/ShhShell/Views/ContentView.swift @@ -43,7 +43,11 @@ struct ContentView: View { } } - + NavigationLink { + SnippetManagerView(hostsManager: hostsManager) + } label: { + Label("Snippets", systemImage: "paperclip") + } NavigationLink { KeyManagerView(hostsManager: hostsManager, keyManager: keyManager) diff --git a/ShhShell/Views/Snippets/SnippetManager.swift b/ShhShell/Views/Snippets/SnippetManager.swift deleted file mode 100644 index e15ce08..0000000 --- a/ShhShell/Views/Snippets/SnippetManager.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// SnippetManager.swift -// ShhShell -// -// Created by neon443 on 18/07/2025. -// - -import SwiftUI - -struct SnippetManager: View { - @ObservedObject var hostsManager: HostsManager - - var body: some View { - - } -} - -#Preview { - SnippetManager(hostsManager: HostsManager()) -} diff --git a/ShhShell/Views/Snippets/SnippetManagerView.swift b/ShhShell/Views/Snippets/SnippetManagerView.swift new file mode 100644 index 0000000..f085008 --- /dev/null +++ b/ShhShell/Views/Snippets/SnippetManagerView.swift @@ -0,0 +1,29 @@ +// +// SnippetManagerView.swift +// ShhShell +// +// Created by neon443 on 18/07/2025. +// + +import SwiftUI + +struct SnippetManagerView: View { + @ObservedObject var hostsManager: HostsManager + + var body: some View { + ForEach(hostsManager.snippets) { snip in + Text(snip.name) + .bold() + .font(.subheadline) + Text(snip.content) + } + .toolbar { + + } + } +} + +#Preview { + SnippetManagerView(hostsManager: HostsManager()) +} +