Add selectedTextForegroundColor to recolor selected text#558
Open
akingundogdu wants to merge 1 commit into
Open
Add selectedTextForegroundColor to recolor selected text#558akingundogdu wants to merge 1 commit into
akingundogdu wants to merge 1 commit into
Conversation
Add an optional selectedTextForegroundColor to the macOS and iOS TerminalViews. When set, selected text is rendered in this color in addition to the existing selectedTextBackgroundColor. When nil (the default), behavior is unchanged: selected text keeps its original foreground color and only the selection background is drawn. This enables themes that define a distinct selection foreground (for example GitHub Dark's dark-on-yellow selection) to render legible selected text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
selectedTextForegroundColorproperty to the macOS (TerminalView/MacTerminalView) and iOS terminal views.When set, selected text is rendered in this color in addition to the existing
selectedTextBackgroundColor. Whennil(the default), behavior is unchanged — selected text keeps its original foreground color and only the selection background is drawn, so this is fully backward compatible and opt-in.Motivation
Several terminal color schemes define a distinct selection foreground alongside the selection background (for example GitHub Dark uses near-black text on a yellow selection). Today only the background can be customized, so selected text can become hard to read against a saturated selection background. This adds parity with terminals/themes that expect a selection foreground.
Changes
Mac/MacTerminalView.swift: addselectedTextForegroundColor: NSColor?(defaultnil).iOS/iOSTerminalView.swift: addselectedTextForegroundColor: UIColor?(defaultnil).Apple/AppleTerminalView.swift: inbuildAttributedString, when a cell is selected, override the foreground attribute withselectedTextForegroundColorif it is set (the existing draw path already honors.foregroundColor).Testing
swift build --target SwiftTermsucceeds.selectedTextForegroundColorrenders legible dark text on a light selection background; leaving itnilpreserves existing behavior.