mirror of
https://github.com/neon443/ShhShell.git
synced 2026-11-30 12:44:51 +00:00
axed some of them bc i cba to find italic, bold, bolditalc ones
removed the 2nd font enum and switched to a computed property for the font name updated the loadfonts thing removed applyselectedtheme from the sshhandler and the init, moved it to didmovetowindow
This commit is contained in:
21 files changed
+122
-67
No files matched your search
+20
-10
@@ -7,16 +7,26 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum Fonts: String, CaseIterable/*, CustomStringConvertible*/ {
|
||||
case mesloLGSNF = "MesloLGS-NF-Regular"
|
||||
case sfMono = "SFMono-Regular"
|
||||
case cascadiaMono = "CascadiaMono-Regular"
|
||||
case geistMonoNF = "GeistMonoNFM-Regular"
|
||||
case jetbrainsMonoNF = "JetBrainsMonoNFM-Regular"
|
||||
case comicSans = "ComicSansMS"
|
||||
case comicMono = "ComicMono"
|
||||
enum FontFamilies: String, CaseIterable, CustomStringConvertible {
|
||||
case mesloLGSNF = "MesloLGS NF"
|
||||
case sfMono = "SF Mono"
|
||||
case cascadiaMono = "Cascadia Mono"
|
||||
case jetbrainsMonoNF = "JetBrainsMono Nerd Font Mono"
|
||||
|
||||
static var fontNames: [String] {
|
||||
return Fonts.allCases.map { $0.rawValue }
|
||||
static var allCasesRaw: [String] {
|
||||
return allCases.map { $0.rawValue }
|
||||
}
|
||||
|
||||
var description: String {
|
||||
switch self {
|
||||
case .mesloLGSNF:
|
||||
"MesloLGS-NF-Regular"
|
||||
case .sfMono:
|
||||
"SFMono-Regular"
|
||||
case .cascadiaMono:
|
||||
"CascadiaMono-Regular"
|
||||
case .jetbrainsMonoNF:
|
||||
"JetBrainsMonoNFM-Regular"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,14 +33,16 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
||||
func loadFonts() {
|
||||
var customFonts: [UIFont] = []
|
||||
for family in UIFont.familyNames.sorted() {
|
||||
let names = UIFont.fontNames(forFamilyName: family)
|
||||
if Fonts.fontNames.contains(names) {
|
||||
print(family)
|
||||
}
|
||||
guard let customFont = UIFont(name: names[0], size: UIFont.systemFontSize) else {
|
||||
fatalError()
|
||||
if FontFamilies.allCasesRaw.contains(family) {
|
||||
if let family = FontFamilies(rawValue: family) {
|
||||
if let customFont = UIFont(name: family.description, size: UIFont.systemFontSize) {
|
||||
customFonts.append(customFont)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
print(customFonts)
|
||||
self.fonts = customFonts
|
||||
}
|
||||
|
||||
func loadThemes() {
|
||||
|
||||
+6
-3
@@ -5,12 +5,15 @@
|
||||
<key>UIAppFonts</key>
|
||||
<array>
|
||||
<string>MesloLGS NF Regular.ttf</string>
|
||||
<string>MesloLGS NF Italic.ttf</string>
|
||||
<string>MesloLGS NF Bold.ttf</string>
|
||||
<string>MesloLGS NF Bold Italic.ttf</string>
|
||||
<string>SF-Mono-Regular.otf</string>
|
||||
<string>CascadiaMono.ttf</string>
|
||||
<string>GeistMonoNerdFontMono-Regular.otf</string>
|
||||
<string>JetBrainsMonoNerdFontMono-Regular.ttf</string>
|
||||
<string>ComicMono.ttf</string>
|
||||
<string>Comic Sans MS.ttf</string>
|
||||
<string>JetBrainsMonoNerdFontMono-Bold.ttf</string>
|
||||
<string>JetBrainsMonoNerdFontMono-Italic.ttf</string>
|
||||
<string>JetBrainsMonoNerdFontMono-BoldItalic.ttf</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -168,14 +168,6 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
|
||||
|
||||
}
|
||||
|
||||
func applySelectedTheme() {
|
||||
Task { @MainActor in
|
||||
guard let sessionID else { return }
|
||||
guard let session = container.sessions[sessionID] else { return }
|
||||
session.terminalView.applySelectedTheme()
|
||||
}
|
||||
}
|
||||
|
||||
func ring() {
|
||||
Task { @MainActor in
|
||||
withAnimation(.easeIn(duration: 0.1)) { self.bell = true }
|
||||
|
||||
@@ -18,11 +18,21 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina
|
||||
self.init(frame: frame)
|
||||
self.handler = handler
|
||||
self.hostsManager = hostsManager
|
||||
|
||||
applySelectedTheme()
|
||||
//fonts here yayy
|
||||
}
|
||||
|
||||
override func didMoveToWindow() {
|
||||
super.didMoveToWindow()
|
||||
if window != nil {
|
||||
restoreScrollback()
|
||||
if let hostsManager {
|
||||
// font = hostsManager.fonts.randomElement() ?? UIFont.systemFont(ofSize: UIFont.systemFontSize)
|
||||
font = UIFont(name: "JetBrainsMono Nerd Font Mono", size: UIFont.systemFontSize)!
|
||||
}
|
||||
applySelectedTheme()
|
||||
}
|
||||
}
|
||||
|
||||
func restoreScrollback() {
|
||||
guard let scrollback = handler?.scrollback else { return }
|
||||
guard !scrollback.isEmpty else { return }
|
||||
@@ -69,13 +79,6 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina
|
||||
// TODO: selectedtext and cursor colors
|
||||
}
|
||||
|
||||
override func didMoveToWindow() {
|
||||
super.didMoveToWindow()
|
||||
if window != nil {
|
||||
restoreScrollback()
|
||||
}
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
terminalDelegate = self
|
||||
|
||||
@@ -31,9 +31,6 @@ struct ShellView: View {
|
||||
}
|
||||
.opacity(handler.bell ? 1 : 0)
|
||||
}
|
||||
.onAppear {
|
||||
handler.applySelectedTheme()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||