diff --git a/Sources/SwiftTerm/Apple/AppleTerminalView.swift b/Sources/SwiftTerm/Apple/AppleTerminalView.swift index 2b509353b..177ba4a16 100644 --- a/Sources/SwiftTerm/Apple/AppleTerminalView.swift +++ b/Sources/SwiftTerm/Apple/AppleTerminalView.swift @@ -645,6 +645,9 @@ extension TerminalView { if isSelected { var mutable = attributes mutable[.selectionBackgroundColor] = selectedTextBackgroundColor + if let selectedTextForegroundColor { + mutable[.foregroundColor] = selectedTextForegroundColor + } currentAttributes = mutable } else { currentAttributes = attributes diff --git a/Sources/SwiftTerm/Mac/MacTerminalView.swift b/Sources/SwiftTerm/Mac/MacTerminalView.swift index 2ce2504c4..4cf92533a 100644 --- a/Sources/SwiftTerm/Mac/MacTerminalView.swift +++ b/Sources/SwiftTerm/Mac/MacTerminalView.swift @@ -476,6 +476,19 @@ open class TerminalView: NSView, NSTextInputClient, NSUserInterfaceValidations, } } + var _selectedTextForegroundColor: NSColor? = nil + /// The color used to render the text of the selection. When `nil` (the default), + /// selected text keeps its original foreground color and only the selection + /// background is drawn. + public var selectedTextForegroundColor: NSColor? { + get { + return _selectedTextForegroundColor + } + set { + _selectedTextForegroundColor = newValue + } + } + func backingScaleFactor () -> CGFloat { window?.backingScaleFactor ?? NSScreen.main?.backingScaleFactor ?? 1 diff --git a/Sources/SwiftTerm/iOS/iOSTerminalView.swift b/Sources/SwiftTerm/iOS/iOSTerminalView.swift index de10761af..dbf2edf95 100644 --- a/Sources/SwiftTerm/iOS/iOSTerminalView.swift +++ b/Sources/SwiftTerm/iOS/iOSTerminalView.swift @@ -1258,6 +1258,19 @@ open class TerminalView: UIScrollView, UITextInputTraits, UIKeyInput, UIScrollVi _selectedTextBackgroundColor = newValue } } + + var _selectedTextForegroundColor: UIColor? = nil + /// The color used to render the text of the selection. When `nil` (the default), + /// selected text keeps its original foreground color and only the selection + /// background is drawn. + public var selectedTextForegroundColor: UIColor? { + get { + return _selectedTextForegroundColor + } + set { + _selectedTextForegroundColor = newValue + } + } var _selectionHandleColor: UIColor = UIColor.systemBlue /// The color used to render the selection handles