Add settings

This commit is contained in:
neon443
2025-09-04 21:02:41 +01:00
parent d39f176f72
commit 6d3b7f2f64
3 changed files with 19 additions and 2 deletions

View File

@@ -7,11 +7,12 @@
import Foundation import Foundation
import SwiftUI import SwiftUI
import SwiftTerm @preconcurrency import SwiftTerm
struct AppSettings: Codable, Sendable, Equatable { struct AppSettings: Codable, Sendable, Equatable {
var scrollback: CGFloat = 10_000 var scrollback: CGFloat = 10_000
var cursorType: CursorType = CursorType() var cursorType: CursorType = CursorType()
var cursorAnimations: CursorAnimations = CursorAnimations()
var locationPersist: Bool = false var locationPersist: Bool = false
var bellSound: Bool = false var bellSound: Bool = false
var bellHaptic: Bool = true var bellHaptic: Bool = true

View File

@@ -29,12 +29,12 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina
restoreScrollback() restoreScrollback()
if let hostsManager { if let hostsManager {
font = UIFont(name: hostsManager.selectedFont, size: hostsManager.fontSize)! font = UIFont(name: hostsManager.selectedFont, size: hostsManager.fontSize)!
getTerminal().setCursorAnimations(hostsManager.settings.cursorAnimations)
} }
applySelectedTheme() applySelectedTheme()
applyScrollbackLength() applyScrollbackLength()
applyCursorType() applyCursorType()
getTerminal().registerOscHandler(code: 133, handler: { _ in }) getTerminal().registerOscHandler(code: 133, handler: { _ in })
getTerminal().setCursorAnimations(CursorAnimations(type: .stretchAndMove, length: 0.2))
self.startFeedLoop() self.startFeedLoop()
let _ = self.becomeFirstResponder() let _ = self.becomeFirstResponder()
} }

View File

@@ -108,6 +108,22 @@ struct SettingsView: View {
} }
.pickerStyle(.inline) .pickerStyle(.inline)
.labelsHidden() .labelsHidden()
Picker("Animation Type", selection: $hostsManager.settings.cursorAnimations.type) {
ForEach(CursorAnimationType.allCases, id: \.self) { animType in
Text(animType.description).tag(animType)
}
}
Slider(value: $hostsManager.settings.cursorAnimations.length, in: 0.05...0.5, step: 0.05) {
Label("Speed", systemImage: "gauge.with.dots.needle.67percent")
}
.disabled(hostsManager.settings.cursorAnimations.type == .none)
Slider(value: $hostsManager.settings.cursorAnimations.stretchMultiplier, in: 0.25...2, step: 0.25) {
Label("Stretch Multiplier", systemImage: "multiply")
}
.disabled(hostsManager.settings.cursorAnimations.type != .stretchAndMove)
} }
Section("Keepalive") { Section("Keepalive") {