Skip to content

Add selectedTextForegroundColor to recolor selected text#558

Open
akingundogdu wants to merge 1 commit into
migueldeicaza:mainfrom
akingundogdu:feature/selectionForegroundColor
Open

Add selectedTextForegroundColor to recolor selected text#558
akingundogdu wants to merge 1 commit into
migueldeicaza:mainfrom
akingundogdu:feature/selectionForegroundColor

Conversation

@akingundogdu

Copy link
Copy Markdown

Summary

Adds an optional selectedTextForegroundColor property to the macOS (TerminalView/MacTerminalView) and iOS terminal views.

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, 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: add selectedTextForegroundColor: NSColor? (default nil).
  • iOS/iOSTerminalView.swift: add selectedTextForegroundColor: UIColor? (default nil).
  • Apple/AppleTerminalView.swift: in buildAttributedString, when a cell is selected, override the foreground attribute with selectedTextForegroundColor if it is set (the existing draw path already honors .foregroundColor).

Testing

  • swift build --target SwiftTerm succeeds.
  • Verified in an embedding app: setting selectedTextForegroundColor renders legible dark text on a light selection background; leaving it nil preserves existing behavior.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant