mirror of
https://github.com/darlinghq/darling-cocotron.git
synced 2024-11-26 21:40:44 +00:00
Implement NSParagraph TabStops properly
Implement NSTextTab handling based on the GNUStep implementation, with formatting and other adjustments.
This commit is contained in:
parent
a4bc3feb11
commit
b3c2e2dea3
@ -128,17 +128,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
}
|
||||
|
||||
- (void) setTabStops: (NSArray *) tabStops {
|
||||
tabStops = [tabStops copy];
|
||||
[_tabStops release];
|
||||
_tabStops = tabStops;
|
||||
if (tabStops != _tabStops) {
|
||||
[_tabStops removeAllObjects];
|
||||
[_tabStops addObjectsFromArray: tabStops];
|
||||
[_tabStops sortUsingSelector: @selector(compare:)];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) addTabStop:(NSTextTab *) tabStop {
|
||||
//NSUnimplementedMethod();
|
||||
- (void) addTabStop: (NSTextTab *) tabStop {
|
||||
NSUInteger index = [_tabStops
|
||||
indexOfObjectPassingTest: ^BOOL(NSTextTab *other, NSUInteger id,
|
||||
BOOL *stop) {
|
||||
return [other compare: tabStop] == NSOrderedAscending;
|
||||
}];
|
||||
|
||||
if (index == NSNotFound) {
|
||||
[_tabStops insertObject: tabStop atIndex: 0];
|
||||
} else {
|
||||
[_tabStops insertObject: tabStop atIndex: index];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) removeTabStop:(NSTextTab *) tabStop {
|
||||
//NSUnimplementedMethod();
|
||||
- (void) removeTabStop: (NSTextTab *) tabStop {
|
||||
[_tabStops removeObject: tabStop];
|
||||
}
|
||||
|
||||
- (void) setHyphenationFactor: (float) factor {
|
||||
|
@ -34,7 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
return shared;
|
||||
}
|
||||
|
||||
+ (NSWritingDirection)defaultWritingDirectionForLanguage:(NSString *)languageName {
|
||||
+ (NSWritingDirection) defaultWritingDirectionForLanguage: (NSString *) languageName {
|
||||
NSUnimplementedMethod();
|
||||
return NSWritingDirectionNatural;
|
||||
}
|
||||
@ -74,7 +74,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
_lineHeightMultiple = 0;
|
||||
_lineSpacing = 0;
|
||||
_defaultTabInterval = 0;
|
||||
_tabStops = [[[self class] _defaultTabStops] retain];
|
||||
_tabStops = [[[self class] _defaultTabStops] mutableCopy];
|
||||
_hyphenationFactor = 0;
|
||||
_tighteningFactorForTruncation = 0;
|
||||
}
|
||||
|
@ -136,4 +136,20 @@ NSString *NSTabColumnTerminatorsAttributeName =
|
||||
return self.location == other.location &&
|
||||
self.tabStopType == other.tabStopType;
|
||||
}
|
||||
|
||||
- (NSComparisonResult) compare: (id) anObject {
|
||||
CGFloat loc;
|
||||
|
||||
if (anObject == self)
|
||||
return NSOrderedSame;
|
||||
if (anObject == nil || ![anObject isKindOfClass: [self class]])
|
||||
return NSOrderedAscending;
|
||||
loc = ((NSTextTab *) anObject)->_location;
|
||||
if (_location < loc)
|
||||
return NSOrderedAscending;
|
||||
else if (_location > loc)
|
||||
return NSOrderedDescending;
|
||||
else
|
||||
return NSOrderedSame;
|
||||
}
|
||||
@end
|
||||
|
@ -48,8 +48,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
|
||||
- (void) setDefaultTabInterval: (CGFloat) interval;
|
||||
- (void) setTabStops: (NSArray *) tabStops;
|
||||
- (void) addTabStop:(NSTextTab *) tabStop;
|
||||
- (void) removeTabStop:(NSTextTab *) tabStop;
|
||||
- (void) addTabStop: (NSTextTab *) tabStop;
|
||||
- (void) removeTabStop: (NSTextTab *) tabStop;
|
||||
|
||||
|
||||
- (void) setHyphenationFactor: (float) factor;
|
||||
|
@ -45,14 +45,14 @@ typedef enum {
|
||||
CGFloat _lineHeightMultiple;
|
||||
CGFloat _lineSpacing;
|
||||
CGFloat _defaultTabInterval;
|
||||
NSArray *_tabStops;
|
||||
NSMutableArray *_tabStops;
|
||||
float _hyphenationFactor;
|
||||
float _tighteningFactorForTruncation;
|
||||
}
|
||||
|
||||
+ (NSParagraphStyle *) defaultParagraphStyle;
|
||||
|
||||
+ (NSWritingDirection)defaultWritingDirectionForLanguage:(NSString *)languageName;
|
||||
+ (NSWritingDirection)defaultWritingDirectionForLanguage: (NSString *)languageName;
|
||||
|
||||
- (NSWritingDirection) baseWritingDirection;
|
||||
|
||||
|
@ -49,4 +49,5 @@ APPKIT_EXPORT NSString *NSTabColumnTerminatorsAttributeName;
|
||||
|
||||
- (CGFloat) location;
|
||||
|
||||
- (NSComparisonResult) compare: (id) anObject;
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user