You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a struct that encapsulates a single change to an NSRange. It's useful for serializing, queuing, or otherwise storing changes and applying them.
You can also use this class to tranform locations, NSRange, or even an IndexSet. This is handy for updating values as text is changed. This might seem easy, but there are a large number of edge cases that RangeMutation handles, including mutations that invalidate (for example completely delete) a range.
Extensions
NSRange
// convenience
staticletzero:NSRangestaticletnotFound:NSRangevarmax:Int
// shifting
func shifted(by delta:Int)->NSRange?func shifted(endBy delta:Int)->NSRange?func shifted(startBy delta:Int)->NSRange?
// mutating
func clamped(to limit:Int)-> NSRange
func apply(_ change:RangeMutation)->NSRange?
// working with Swift String
func range(in string: String)->Range<String.Index>?
I would love to hear from you! Issues or pull requests work great. Both a Matrix space and Discord are available for live help, but I have a strong bias towards answering in the form of documentation. You can also find me on mastodon.
I prefer collaboration, and would love to find ways to work together if you have a similar project.
I prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.