Skip to content

Commit

Permalink
README updates, some comment docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Jul 7, 2019
1 parent 219389d commit 6e41fc1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,40 @@ Carthage:
github "ChimeHQ/Rearrange"
```

## Types

**RangeMutation**

This is a struct that encapsulates a single change to an NSRange. Its useful for serializing, queuing, or otherise storing changes and applying them.

You can also use this class to tranform individual points or other NSRanges. This is useful 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**

```swift
// convenience
static var zero
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
func apply(_ change: RangeMutation) -> NSRange?
```

**IndexSet**

```swift
mutating func insert(range: NSRange)
mutating func insert(ranges: [NSRange])
var nsRangeView: [NSRange]
```

### Suggestions or Feedback

We'd love to hear from you! Get in touch via [twitter](https://twitter.com/chimehq), an issue, or a pull request.
Expand Down
4 changes: 4 additions & 0 deletions Rearrange.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,14 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
MACH_O_TYPE = staticlib;
MARKETING_VERSION = 1.1;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -390,12 +392,14 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
MACH_O_TYPE = staticlib;
MARKETING_VERSION = 1.1;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
Expand Down
2 changes: 1 addition & 1 deletion Rearrange/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion Rearrange/NSRange+Convenience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension NSRange {
}

extension NSRange {
public var max : Int {
public var max: Int {
return NSMaxRange(self)
}
}
1 change: 1 addition & 0 deletions Rearrange/RangeMutation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation

/// RangeMutation encapsulates a single change in a larger NSRange, like a text representation.
public struct RangeMutation {
public let range: NSRange
public let delta: Int
Expand Down
2 changes: 1 addition & 1 deletion Rearrange/Rearrange.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
PRODUCT_NAME = Rearrange
PRODUCT_BUNDLE_IDENTIFIER = com.chimehq.Rearrange
PRODUCT_MODULE_NAME = Rearrange
CURRENT_PROJECT_VERSION = 1
CURRENT_PROJECT_VERSION = 2

INFOPLIST_FILE = Rearrange/Info.plist

Expand Down

0 comments on commit 6e41fc1

Please sign in to comment.