Skip to content

Commit

Permalink
Merge pull request #348 from thecoolwinter/fix/caret-clipping-macos
Browse files Browse the repository at this point in the history
Fix Caret Drawing Artifacts
  • Loading branch information
migueldeicaza authored Aug 8, 2024
2 parents e9cfa44 + c0b7887 commit c0ba497
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/SwiftTerm/Apple/CaretView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ extension CaretView {
guard let terminal else {
return
}
context.saveGState()
context.clip(to: [bounds])
context.setFillColor(TTColor.clear.cgColor)
context.fill ([bounds])

if !hasFocus {
context.setStrokeColor(bgColor)
context.setLineWidth(2)
context.setLineWidth(3)
context.stroke(bounds)
return
}
Expand Down Expand Up @@ -61,5 +63,6 @@ extension CaretView {
}
CTFontDrawGlyphs(runFont, runGlyphs, &positions, positions.count, context)
}
context.restoreGState()
}
}
1 change: 1 addition & 0 deletions Sources/SwiftTerm/Mac/MacCaretView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class CaretView: NSView, CALayerDelegate {

public var caretColor: NSColor = NSColor.selectedControlColor {
didSet {
bgColor = caretColor.cgColor
updateView()
}
}
Expand Down

0 comments on commit c0ba497

Please sign in to comment.