Skip to content

Commit 65816ba

Browse files
committed
Add NSCursor extensions.
1 parent c4a6636 commit 65816ba

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

Attributed.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
43C994151BE3DE8900CF90DD /* PlatformTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C993E81BE3BDC000CF90DD /* PlatformTypes.swift */; };
4545
43C994161BE3DE8E00CF90DD /* AttributedStringConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C993F01BE3C9CE00CF90DD /* AttributedStringConvertibleTests.swift */; };
4646
43CDB1E41BE3FE6800440B11 /* AttributedTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C993D71BE3B9C700CF90DD /* AttributedTests.swift */; };
47+
43D5EA131BFF5FE200E48BD6 /* NSCursor+Attributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43D5EA121BFF5FE200E48BD6 /* NSCursor+Attributes.swift */; };
4748
/* End PBXBuildFile section */
4849

4950
/* Begin PBXContainerItemProxy section */
@@ -88,6 +89,7 @@
8889
43C993F01BE3C9CE00CF90DD /* AttributedStringConvertibleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttributedStringConvertibleTests.swift; sourceTree = "<group>"; };
8990
43C993F91BE3DDF800CF90DD /* Attributed.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Attributed.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9091
43C994021BE3DDF900CF90DD /* Attributed-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Attributed-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
92+
43D5EA121BFF5FE200E48BD6 /* NSCursor+Attributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSCursor+Attributes.swift"; sourceTree = "<group>"; };
9193
/* End PBXFileReference section */
9294

9395
/* Begin PBXFrameworksBuildPhase section */
@@ -151,6 +153,7 @@
151153
43C752301BEA525100F928E5 /* ColorType+Attributes.swift */,
152154
43C752361BEA5F0A00F928E5 /* FontType+Attributes.swift */,
153155
43C7523F1BEA61B000F928E5 /* Ligature+Attributes.swift */,
156+
43D5EA121BFF5FE200E48BD6 /* NSCursor+Attributes.swift */,
154157
43C752451BEA6B1400F928E5 /* NSNumberConvertible+Attributes.swift */,
155158
43C7523C1BEA610A00F928E5 /* NSParagraphStyle+Attributes.swift */,
156159
434DBBC91BEC3AD000C11F09 /* NSShadow+Attributes.swift */,
@@ -380,6 +383,7 @@
380383
434DBBCA1BEC3AD000C11F09 /* NSShadow+Attributes.swift in Sources */,
381384
43C752401BEA61B000F928E5 /* Ligature+Attributes.swift in Sources */,
382385
43C993E51BE3BAD300CF90DD /* NestedAttributedString.swift in Sources */,
386+
43D5EA131BFF5FE200E48BD6 /* NSCursor+Attributes.swift in Sources */,
383387
434DBBC81BEC39FA00C11F09 /* NSUnderlineStyle+Attributes.swift in Sources */,
384388
43C7523D1BEA610A00F928E5 /* NSParagraphStyle+Attributes.swift in Sources */,
385389
43C993E31BE3BAA100CF90DD /* Functions.swift in Sources */,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Attributed
2+
// Written in 2015 by Nate Stedman <[email protected]>
3+
//
4+
// To the extent possible under law, the author(s) have dedicated all copyright and
5+
// related and neighboring rights to this software to the public domain worldwide.
6+
// This software is distributed without any warranty.
7+
//
8+
// You should have received a copy of the CC0 Public Domain Dedication along with
9+
// this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
10+
11+
#if os(OSX)
12+
13+
import AppKit
14+
15+
extension NSCursor
16+
{
17+
/**
18+
Applies a cursor to the enclosed attributed strings.
19+
20+
The cursor will not override a cursor set deeper in the hierarchy.
21+
22+
- parameter strings: The attributed strings to apply the shadow to.
23+
*/
24+
public func attribute(strings: AttributedStringConvertible...) -> AttributedStringConvertible
25+
{
26+
return Attributed.attribute(NSCursorAttributeName, self, strings)
27+
}
28+
29+
/**
30+
Applies a cursor to the enclosed attributed strings.
31+
32+
The cursor will not override a cursor set deeper in the hierarchy.
33+
34+
- parameter strings: The attributed strings to apply the cursor to.
35+
*/
36+
public func attribute(strings: [AttributedStringConvertible]) -> AttributedStringConvertible
37+
{
38+
return Attributed.attribute(NSCursorAttributeName, self, strings)
39+
}
40+
}
41+
42+
#endif

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ The provided attribute functions take the value of the attribute as the first va
5858
#### Other Framework Types
5959
These additional framework types are extended with attribute functions:
6060

61+
- `NSCursor`, on OS X only: `attributes`, which maps to `NSCursorAttributeName`.
6162
- `NSFont`/`UIFont`: `attribute`, which maps to `NSFontAttributeName`.
6263
- `NSTextAttachment`: `attribute`, which maps to `NSAttachmentAttributeName`.
6364
- `NSParagraphStyle`: `attribute`, which maps to `NSParagraphStyleAttributeName`.

0 commit comments

Comments
 (0)