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

Added property insertionPointWidth #3

Merged

Conversation

lukepistrol
Copy link
Contributor

Added insertionPointWidth to STTextView to make it possible to change the width of the insertion point.

Test result with a width of 10pt:

var textView = STTextView()
textView.insertionPointWidth = 10.0

Screen Shot 2022-05-28 at 18 05 11

@krzyzanowskim
Copy link
Owner

krzyzanowskim commented May 28, 2022

thanks! that's a valid request. I prefer providing a customization point for the insertion point (I had it once, then removed it for simplicity) rather than adding customization attributes to STTextView itself.

I just added an API that allows customizing insertion points. Maybe I move it to delegate later, but for now, it's good how it is. The pattern is akin to UIView.layerClass or NSControl.cellClass.

It works like this:

textView.insertionPointLayerClass = WideCodeInsertionPointLayer.self
class WideCodeInsertionPointLayer: STInsertionPointLayer {
    override var insertionPointWidth: CGFloat {
        10
    }

    override var insertionPointColor: NSColor {
        NSColor.yellow
    }
}

@krzyzanowskim
Copy link
Owner

that said. I'm going to merge this PR, but it may change in the future. I'd prefer to not add more insertion point customization properties to the STTextView class itself.

@krzyzanowskim krzyzanowskim merged commit 8b5f3c6 into krzyzanowskim:main May 28, 2022
@lukepistrol
Copy link
Contributor Author

Yeah that might be a better approach after all. Really like what you've done so far!

@lukepistrol lukepistrol deleted the feature/insertion-point-width branch May 28, 2022 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants