All Projects → ChimeHQ → Rearrange

ChimeHQ / Rearrange

Licence: BSD-3-Clause License
Collection of utilities for interacting with NSRange and NSTextRange

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to Rearrange

ProcessEnv
Capture the shell environment of a Foundation app
Stars: ✭ 16 (-42.86%)
Mutual labels:  foundation, cocoa
Fruity
Rusty bindings for Apple libraries
Stars: ✭ 72 (+157.14%)
Mutual labels:  foundation, cocoa
Cocoatextfield
Apple TextField created according to the Material.IO guidelines of 2019. Featured at Medium.
Stars: ✭ 195 (+596.43%)
Mutual labels:  uitextview, cocoa
OperationPlus
NSOperation's missing pieces
Stars: ✭ 119 (+325%)
Mutual labels:  foundation, cocoa
Objcxx
Stars: ✭ 54 (+92.86%)
Mutual labels:  foundation, cocoa
TextViewPlus
Collection of useful extensions when working with NSTextView
Stars: ✭ 28 (+0%)
Mutual labels:  cocoa, nstextview
AMXFontAutoScale
⚠️ Experimental automatic cross-device font scaling for UILabel and UITextView.
Stars: ✭ 39 (+39.29%)
Mutual labels:  uitextview
Fab
🛍️ A Floating Action Button for macOS. Inspired by Material Design, and written in Swift.
Stars: ✭ 24 (-14.29%)
Mutual labels:  cocoa
FoundationNavWalker
A simple extension of wp_nav_menu to support Foundation 5's offcanvas nav
Stars: ✭ 17 (-39.29%)
Mutual labels:  foundation
Sukari
🍯 Sweet Syntactical Sugar For Swift
Stars: ✭ 30 (+7.14%)
Mutual labels:  foundation
LycricsTextView
No description or website provided.
Stars: ✭ 14 (-50%)
Mutual labels:  uitextview
TextStory
Happier, more flexible NSTextStorage
Stars: ✭ 60 (+114.29%)
Mutual labels:  nstextview
foundation
Interactions with the CDF Staff and Board
Stars: ✭ 20 (-28.57%)
Mutual labels:  foundation
Extras
Just some extras..
Stars: ✭ 17 (-39.29%)
Mutual labels:  foundation
core
🔥 Antares Core Implemenation. Most important project layer, this is the heart for your app. ACL, notifiter, console, geoip, areas, utils and many more...
Stars: ✭ 24 (-14.29%)
Mutual labels:  foundation
governance
TODO Group Governance
Stars: ✭ 69 (+146.43%)
Mutual labels:  foundation
CocoaHeadsNL-iOS
Repository for CocoaHeadsNL app.
Stars: ✭ 54 (+92.86%)
Mutual labels:  cocoa
BlockiesSwift
Unique blocky identicons generator for Swift
Stars: ✭ 53 (+89.29%)
Mutual labels:  cocoa
ruby-china-reader
Simple Mac Reader for Ruby China
Stars: ✭ 48 (+71.43%)
Mutual labels:  cocoa
typedesigner
Unified Font Object Editor for macOS
Stars: ✭ 20 (-28.57%)
Mutual labels:  cocoa

Build Status License Platforms

Rearrange

Rearrange is a collection of utilities for making it easier to work with NSRange and NSTextRange. It's particularly handy when used with the Cocoa text system.

Integration

Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/ChimeHQ/Rearrange")
]

Types

RangeMutation

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 individual points or other NSRanges. This is handy for updating a set of stored NSRanges 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
static var zero: NSRange
static var notFound: NSRange
var max: Int

// shifting
public func shifted(by delta: Int) -> NSRange?
public func shifted(startBy delta: Int) -> NSRange?
public func shifted(endBy delta: Int) -> NSRange?

// mutating
public func clamped(to limit: Int) -> NSRange

func apply(_ change: RangeMutation) -> NSRange?

// creating
init(_ textRange: NSTextRange, provider: NSTextElementProvider)

NSTextRange

// creating
convenience init?(_ range: NSRange, provider: NSTextElementProvider)
convenience init?(_ offset: Int, provider: NSTextElementProvider)

IndexSet

mutating func insert(range: NSRange)
mutating func insert(ranges: [NSRange])
mutating func remove(integersIn range: NSRange)
var nsRangeView: [NSRange]
func contains(integersIn range: NSRange) -> Bool
func intersects(integersIn range: NSRange) -> Bool
var limitSpanningRange: NSRange?

Suggestions or Feedback

We'd love to hear from you! Get in touch via twitter, an issue, or a pull request.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].