Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gutter Drawing Code #234

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions Sources/CodeEditSourceEditor/Gutter/GutterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import AppKit
import CodeEditTextView
import CodeEditTextViewObjC

public protocol GutterViewDelegate: AnyObject {
func gutterViewWidthDidUpdate(newWidth: CGFloat)
Expand Down Expand Up @@ -55,10 +56,6 @@ public class GutterView: NSView {
true
}

override public var wantsDefaultClipping: Bool {
false
}

public init(
font: NSFont,
textColor: NSColor,
Expand All @@ -71,11 +68,11 @@ public class GutterView: NSView {
self.delegate = delegate

super.init(frame: .zero)
clipsToBounds = false
clipsToBounds = true
wantsLayer = true
layerContentsRedrawPolicy = .onSetNeedsDisplay
translatesAutoresizingMaskIntoConstraints = false
layer?.masksToBounds = false
layer?.masksToBounds = true

NotificationCenter.default.addObserver(
forName: TextSelectionManager.selectionChangedNotification,
Expand Down Expand Up @@ -165,6 +162,16 @@ public class GutterView: NSView {
}

context.saveGState()

context.setAllowsAntialiasing(true)
context.setShouldAntialias(true)
context.setAllowsFontSmoothing(false)
context.setAllowsFontSubpixelPositioning(true)
context.setShouldSubpixelPositionFonts(true)
context.setAllowsFontSubpixelQuantization(true)
context.setShouldSubpixelQuantizeFonts(true)
ContextSetHiddenSmoothingStyle(context, 16)

context.textMatrix = CGAffineTransform(scaleX: 1, y: -1)
for linePosition in textView.layoutManager.visibleLines() {
if selectionRangeMap.intersects(integersIn: linePosition.range) {
Expand Down
Loading