mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 17:52:42 +00:00
Merge pull request #31 from gnustep/bug33397_missing_scriptability_attributes
Bug33397 missing scriptability attributes
This commit is contained in:
commit
5501a43bd0
2 changed files with 108 additions and 0 deletions
|
@ -43,6 +43,7 @@
|
|||
@class NSString;
|
||||
@class GSLayoutManager;
|
||||
@class NSFont;
|
||||
@class NSColor;
|
||||
|
||||
/*
|
||||
* When edit:range:changeInLength: is called, it takes a mask saying
|
||||
|
@ -188,6 +189,31 @@ enum
|
|||
*/
|
||||
- (NSFont*) font;
|
||||
- (void) setFont: (NSFont*)font;
|
||||
|
||||
/*
|
||||
* The text storage contents as an array of attribute runs.
|
||||
*/
|
||||
- (NSArray *)attributeRuns;
|
||||
|
||||
/*
|
||||
* The text storage contents as an array of paragraphs.
|
||||
*/
|
||||
- (NSArray *)paragraphs;
|
||||
|
||||
/*
|
||||
* The text storage contents as an array of words.
|
||||
*/
|
||||
- (NSArray *)words;
|
||||
|
||||
/*
|
||||
* The text storage contents as an array of characters.
|
||||
*/
|
||||
- (NSArray *)characters;
|
||||
|
||||
/*
|
||||
* The font color used when drawing text.
|
||||
*/
|
||||
- (NSColor *)foregroundColor;
|
||||
@end
|
||||
|
||||
/**** Notifications ****/
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#import <Foundation/NSPortCoder.h>
|
||||
#import "AppKit/NSAttributedString.h"
|
||||
#import "AppKit/NSTextStorage.h"
|
||||
#import "AppKit/NSColor.h"
|
||||
#import "GNUstepGUI/GSLayoutManager.h"
|
||||
#import "GSTextStorage.h"
|
||||
|
||||
|
@ -398,4 +399,85 @@ static NSNotificationCenter *nc = nil;
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The text storage contents as an array of attribute runs.
|
||||
*/
|
||||
- (NSArray *)attributeRuns
|
||||
{
|
||||
// Return nothing for now
|
||||
return [NSArray array];
|
||||
}
|
||||
|
||||
/*
|
||||
* The text storage contents as an array of paragraphs.
|
||||
*/
|
||||
- (NSArray *)paragraphs
|
||||
{
|
||||
NSArray *array = [[self string] componentsSeparatedByCharactersInSet:
|
||||
[NSCharacterSet newlineCharacterSet]];
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
NSEnumerator *en = [array objectEnumerator];
|
||||
NSString *obj = nil;
|
||||
|
||||
while((obj = [en nextObject]) != nil)
|
||||
{
|
||||
NSTextStorage *s = AUTORELEASE([[NSTextStorage alloc] initWithString: obj]);
|
||||
[result addObject: s];
|
||||
}
|
||||
|
||||
return [NSArray arrayWithArray: result]; // make immutable
|
||||
}
|
||||
|
||||
/*
|
||||
* The text storage contents as an array of words.
|
||||
*/
|
||||
- (NSArray *)words
|
||||
{
|
||||
NSArray *array = [[self string] componentsSeparatedByCharactersInSet:
|
||||
[NSCharacterSet whitespaceCharacterSet]];
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
NSEnumerator *en = [array objectEnumerator];
|
||||
NSString *obj = nil;
|
||||
|
||||
while((obj = [en nextObject]) != nil)
|
||||
{
|
||||
NSTextStorage *s = AUTORELEASE([[NSTextStorage alloc] initWithString: obj]);
|
||||
[result addObject: s];
|
||||
}
|
||||
|
||||
return [NSArray arrayWithArray: result]; // make immutable
|
||||
}
|
||||
|
||||
/*
|
||||
* The text storage contents as an array of characters.
|
||||
*/
|
||||
- (NSArray *)characters
|
||||
{
|
||||
NSMutableArray *array = [NSMutableArray array];
|
||||
NSUInteger len = [self length];
|
||||
NSUInteger i = 0;
|
||||
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
NSRange r = NSMakeRange(i,1);
|
||||
NSString *c = [[self string] substringWithRange: r];
|
||||
NSTextStorage *s = AUTORELEASE([[NSTextStorage alloc] initWithString: c]);
|
||||
[array addObject: s];
|
||||
}
|
||||
|
||||
return [NSArray arrayWithArray: array]; // make immutable
|
||||
}
|
||||
|
||||
/*
|
||||
* The font color used when drawing text.
|
||||
*/
|
||||
- (NSColor *)foregroundColor
|
||||
{
|
||||
NSRange r = NSMakeRange(0, [self length]);
|
||||
NSDictionary *d = [self fontAttributesInRange: r];
|
||||
NSColor *c = (NSColor *)[d objectForKey: NSForegroundColorAttributeName];
|
||||
return c;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue