added cursor type stuff

updated picker
This commit is contained in:
neon443
2025-08-22 23:50:04 +01:00
parent 9b1b04d755
commit 657bd33eef
2 changed files with 32 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ import SwiftTerm
struct AppSettings: Codable, Sendable, Equatable { struct AppSettings: Codable, Sendable, Equatable {
var scrollback: CGFloat = 10_000 var scrollback: CGFloat = 10_000
var cursorStyle: CursorShape = .block var cursorType: CursorType = CursorType()
var locationPersist: Bool = false var locationPersist: Bool = false
var bellSound: Bool = false var bellSound: Bool = false
var bellHaptic: Bool = true var bellHaptic: Bool = true
@@ -23,6 +23,7 @@ struct AppSettings: Codable, Sendable, Equatable {
enum CursorShape: Codable, CaseIterable, Equatable, CustomStringConvertible { enum CursorShape: Codable, CaseIterable, Equatable, CustomStringConvertible {
case block case block
case bar case bar
case underline
var description: String { var description: String {
switch self { switch self {
@@ -30,10 +31,32 @@ enum CursorShape: Codable, CaseIterable, Equatable, CustomStringConvertible {
return "Block" return "Block"
case .bar: case .bar:
return "Bar" return "Bar"
case .underline:
return "Underline"
} }
} }
} }
struct CursorType: Codable, Equatable, CustomStringConvertible {
var cursorShape: CursorShape = .block
var blink: Bool = true
var stCursorStyle: SwiftTerm.CursorStyle {
switch cursorShape {
case .block:
return blink ? .blinkBlock : .steadyBlock
case .bar:
return blink ? .blinkBar : .steadyBar
case .underline:
return blink ? .blinkUnderline : .steadyUnderline
}
}
var description: String {
return (blink ? "Blinking" : "Steady") + " " + cursorShape.description
}
}
enum TerminalFilter: Codable, CaseIterable, Equatable, CustomStringConvertible { enum TerminalFilter: Codable, CaseIterable, Equatable, CustomStringConvertible {
case none case none
case crt case crt

View File

@@ -26,12 +26,18 @@ struct SettingsView: View {
} }
Slider( Slider(
value: $hostsManager.settings.scrollback, value: $hostsManager.settings.scrollback,
in: 1_000...50_000, in: 100...10_000,
step: 1_000.0 step: 1_000.0
) )
} }
Picker("Cursor", selection: $hostsManager.settings.cursorStyle) { Picker("Blink", selection: $hostsManager.settings.cursorType.blink) {
Text("Blink").tag(true)
Text("Steady").tag(false)
}
.pickerStyle(.segmented)
Picker("Cursor", selection: $hostsManager.settings.cursorType.cursorShape) {
ForEach(CursorShape.allCases, id: \.self) { type in ForEach(CursorShape.allCases, id: \.self) { type in
Text(type.description).tag(type) Text(type.description).tag(type)
} }