Merge pull request #29 from CKegel/TextEdit_patches

AppKit Improvements (Getting TextEdit to compile and Run)
This commit is contained in:
CuriousTommy 2024-08-17 09:41:09 -07:00 committed by GitHub
commit be9227b9ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 831 additions and 243 deletions

View File

@ -27,108 +27,95 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSStringDrawer.h> #import <AppKit/NSStringDrawer.h>
#import <AppKit/NSTextAttachment.h> #import <AppKit/NSTextAttachment.h>
NSString *const NSFontAttributeName = @"NSFontAttributeName"; NSAttributedStringKey NSFontAttributeName = @"NSFontAttributeName";
NSString *const NSParagraphStyleAttributeName = NSAttributedStringKey NSParagraphStyleAttributeName = @"NSParagraphStyleAttributeName";
@"NSParagraphStyleAttributeName"; NSAttributedStringKey NSForegroundColorAttributeName = @"NSForegroundColorAttributeName";
NSString *const NSForegroundColorAttributeName = NSAttributedStringKey NSBackgroundColorAttributeName = @"NSBackgroundColorAttributeName";
@"NSForegroundColorAttributeName"; NSAttributedStringKey NSUnderlineStyleAttributeName = @"NSUnderlineStyleAttributeName";
NSString *const NSBackgroundColorAttributeName = NSAttributedStringKey NSUnderlineColorAttributeName = @"NSUnderlineColorAttributeName";
@"NSBackgroundColorAttributeName"; NSAttributedStringKey NSAttachmentAttributeName = @"NSAttachmentAttributeName";
NSString *const NSUnderlineStyleAttributeName = NSAttributedStringKey NSKernAttributeName = @"NSKernAttributeName";
@"NSUnderlineStyleAttributeName"; NSAttributedStringKey NSLigatureAttributeName = @"NSLigatureAttributeName";
NSString *const NSUnderlineColorAttributeName = NSAttributedStringKey NSStrikethroughStyleAttributeName = @"NSStrikethroughStyleAttributeName";
@"NSUnderlineColorAttributeName"; NSAttributedStringKey NSStrikethroughColorAttributeName = @"NSStrikethroughColorAttributeName";
NSString *const NSAttachmentAttributeName = @"NSAttachmentAttributeName"; NSAttributedStringKey NSObliquenessAttributeName = @"NSObliquenessAttributeName";
NSString *const NSKernAttributeName = @"NSKernAttributeName"; NSAttributedStringKey NSStrokeWidthAttributeName = @"NSStrokeWidthAttributeName";
NSString *const NSLigatureAttributeName = @"NSLigatureAttributeName"; NSAttributedStringKey NSStrokeColorAttributeName = @"NSStrokeColorAttributeName";
NSString *const NSStrikethroughStyleAttributeName = NSAttributedStringKey NSBaselineOffsetAttributeName = @"NSBaselineOffsetAttributeName";
@"NSStrikethroughStyleAttributeName"; NSAttributedStringKey NSSuperscriptAttributeName = @"NSSuperscriptAttributeName";
NSString *const NSStrikethroughColorAttributeName = NSAttributedStringKey NSLinkAttributeName = @"NSLinkAttributeName";
@"NSStrikethroughColorAttributeName"; NSAttributedStringKey NSShadowAttributeName = @"NSShadowAttributeName";
NSString *const NSObliquenessAttributeName = @"NSObliquenessAttributeName"; NSAttributedStringKey NSExpansionAttributeName = @"NSExpansionAttributeName";
NSString *const NSStrokeWidthAttributeName = @"NSStrokeWidthAttributeName"; NSAttributedStringKey NSCursorAttributeName = @"NSCursorAttributeName";
NSString *const NSStrokeColorAttributeName = @"NSStrokeColorAttributeName"; NSAttributedStringKey NSToolTipAttributeName = @"NSToolTipAttributeName";
NSString *const NSBaselineOffsetAttributeName = NSAttributedStringKey NSSpellingStateAttributeName = @"NSSpellingStateAttributeName"; // temporary attribute
@"NSBaselineOffsetAttributeName";
NSString *const NSSuperscriptAttributeName = @"NSSuperscriptAttributeName";
NSString *const NSLinkAttributeName = @"NSLinkAttributeName";
NSString *const NSShadowAttributeName = @"NSShadowAttributeName";
NSString *const NSExpansionAttributeName = @"NSExpansionAttributeName";
NSString *const NSCursorAttributeName = @"NSCursorAttributeName";
NSString *const NSToolTipAttributeName = @"NSToolTipAttributeName";
NSString *const NSSpellingStateAttributeName =
@"NSSpellingStateAttributeName"; // temporary attribute
NSString *const NSDocumentTypeDocumentAttribute = @"DocumentType"; NSAttributedStringDocumentAttributeKey NSDocumentTypeDocumentAttribute = @"DocumentType";
NSString *const NSConvertedDocumentAttribute = @"Converted"; NSAttributedStringDocumentAttributeKey NSConvertedDocumentAttribute = @"Converted";
NSString *const NSFileTypeDocumentAttribute = @"UTI"; NSAttributedStringDocumentAttributeKey NSFileTypeDocumentAttribute = @"UTI";
NSString *const NSTitleDocumentAttribute = @"NSTitleDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSTitleDocumentAttribute = @"NSTitleDocumentAttribute";
NSString *const NSCompanyDocumentAttribute = @"NSCompanyDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSCompanyDocumentAttribute = @"NSCompanyDocumentAttribute";
NSString *const NSCopyrightDocumentAttribute = @"NSCopyrightDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSCopyrightDocumentAttribute = @"NSCopyrightDocumentAttribute";
NSString *const NSSubjectDocumentAttribute = @"NSSubjectDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSSubjectDocumentAttribute = @"NSSubjectDocumentAttribute";
NSString *const NSAuthorDocumentAttribute = @"NSAuthorDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSAuthorDocumentAttribute = @"NSAuthorDocumentAttribute";
NSString *const NSKeywordsDocumentAttribute = @"NSKeywordsDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSKeywordsDocumentAttribute = @"NSKeywordsDocumentAttribute";
NSString *const NSCommentDocumentAttribute = @"NSCommentDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSCommentDocumentAttribute = @"NSCommentDocumentAttribute";
NSString *const NSEditorDocumentAttribute = @"NSEditorDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSEditorDocumentAttribute = @"NSEditorDocumentAttribute";
NSString *const NSCreationTimeDocumentAttribute = NSAttributedStringDocumentAttributeKey NSCreationTimeDocumentAttribute = @"NSCreationTimeDocumentAttribute";
@"NSCreationTimeDocumentAttribute"; NSAttributedStringKey NSModificationTimeDocumentAttribute = @"NSModificationTimeDocumentAttribute";
NSString *const NSModificationTimeDocumentAttribute = NSAttributedStringDocumentAttributeKey NSManagerDocumentAttribute = @"NSManagerDocumentAttribute";
@"NSModificationTimeDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSCategoryDocumentAttribute = @"NSCategoryDocumentAttribute";
NSString *const NSManagerDocumentAttribute = @"NSManagerDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSAppearanceDocumentAttribute = @"NSAppearanceDocumentAttribute";
NSString *const NSCategoryDocumentAttribute = @"NSCategoryDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSCharacterEncodingDocumentAttribute = @"CharacterEncoding";
NSString *const NSAppearanceDocumentAttribute = NSAttributedStringDocumentAttributeKey NSDefaultAttributesDocumentAttribute = @"DefaultAttributes";
@"NSAppearanceDocumentAttribute"; NSAttributedStringDocumentAttributeKey NSPaperSizeDocumentAttribute = @"PaperSize";
NSString *const NSCharacterEncodingDocumentAttribute = @"CharacterEncoding"; NSAttributedStringDocumentAttributeKey NSLeftMarginDocumentAttribute = @"LeftMargin";
NSString *const NSDefaultAttributesDocumentAttribute = @"DefaultAttributes"; NSAttributedStringDocumentAttributeKey NSRightMarginDocumentAttribute = @"RightMargin";
NSString *const NSPaperSizeDocumentAttribute = @"PaperSize"; NSAttributedStringDocumentAttributeKey NSTopMarginDocumentAttribute = @"TopMargin";
NSString *const NSLeftMarginDocumentAttribute = @"LeftMargin"; NSAttributedStringDocumentAttributeKey NSBottomMarginDocumentAttribute = @"BottomMargin";
NSString *const NSRightMarginDocumentAttribute = @"RightMargin"; NSAttributedStringDocumentAttributeKey NSViewSizeDocumentAttribute = @"ViewSize";
NSString *const NSTopMarginDocumentAttribute = @"TopMargin"; NSAttributedStringDocumentAttributeKey NSViewZoomDocumentAttribute = @"ViewZoom";
NSString *const NSBottomMarginDocumentAttribute = @"BottomMargin"; NSAttributedStringDocumentAttributeKey NSViewModeDocumentAttribute = @"ViewMode";
NSString *const NSViewSizeDocumentAttribute = @"ViewSize"; NSAttributedStringDocumentAttributeKey NSReadOnlyDocumentAttribute = @"ReadOnly";
NSString *const NSViewZoomDocumentAttribute = @"ViewZoom"; NSAttributedStringDocumentAttributeKey NSBackgroundColorDocumentAttribute = @"BackgroundColor";
NSString *const NSViewModeDocumentAttribute = @"ViewMode"; NSAttributedStringDocumentAttributeKey NSHyphenationFactorDocumentAttribute = @"HyphenationFactor";
NSString *const NSReadOnlyDocumentAttribute = @"ReadOnly"; NSAttributedStringDocumentAttributeKey NSDefaultTabIntervalDocumentAttribute = @"DefaultTabInterval";
NSString *const NSBackgroundColorDocumentAttribute = @"BackgroundColor"; NSAttributedStringDocumentAttributeKey NSTextLayoutSectionsAttribute = @"NSTextLayoutSectionsAttribute";
NSString *const NSHyphenationFactorDocumentAttribute = @"HyphenationFactor"; NSAttributedStringDocumentAttributeKey NSExcludedElementsDocumentAttribute = @"ExcludedElements";
NSString *const NSDefaultTabIntervalDocumentAttribute = @"DefaultTabInterval"; NSAttributedStringDocumentAttributeKey NSTextEncodingNameDocumentAttribute = @"TextEncodingName";
NSString *const NSTextLayoutSectionsAttribute = NSAttributedStringDocumentAttributeKey NSPrefixSpacesDocumentAttribute = @"PrefixSpaces";
@"NSTextLayoutSectionsAttribute"; NSAttributedStringDocumentAttributeKey NSCocoaVersionDocumentAttribute = @"NSCocoaVersionDocumentAttribute";
NSString *const NSExcludedElementsDocumentAttribute = @"ExcludedElements";
NSString *const NSTextEncodingNameDocumentAttribute = @"TextEncodingName";
NSString *const NSPrefixSpacesDocumentAttribute = @"PrefixSpaces";
NSString *const NSDocumentTypeDocumentOption = @"DocumentType"; NSAttributedStringDocumentReadingOptionKey NSDocumentTypeDocumentOption = @"DocumentType";
NSString *const NSDefaultAttributesDocumentOption = @"DefaultAttributes"; NSAttributedStringDocumentReadingOptionKey NSDefaultAttributesDocumentOption = @"DefaultAttributes";
NSString *const NSCharacterEncodingDocumentOption = @"CharacterEncoding"; NSAttributedStringDocumentReadingOptionKey NSCharacterEncodingDocumentOption = @"CharacterEncoding";
NSString *const NSTextEncodingNameDocumentOption = @"TextEncodingName"; NSAttributedStringDocumentReadingOptionKey NSTextEncodingNameDocumentOption = @"TextEncodingName";
NSString *const NSBaseURLDocumentOption = @"BaseURL"; NSAttributedStringDocumentReadingOptionKey NSBaseURLDocumentOption = @"BaseURL";
NSString *const NSTimeoutDocumentOption = @"Timeout"; NSAttributedStringDocumentReadingOptionKey NSTimeoutDocumentOption = @"Timeout";
NSString *const NSWebPreferencesDocumentOption = @"WebPreferences"; NSAttributedStringDocumentReadingOptionKey NSWebPreferencesDocumentOption = @"WebPreferences";
NSString *const NSWebResourceLoadDelegateDocumentOption = NSAttributedStringDocumentReadingOptionKey NSWebResourceLoadDelegateDocumentOption = @"WebResourceLoadDelegate";
@"WebResourceLoadDelegate"; NSAttributedStringDocumentReadingOptionKey NSTextSizeMultiplierDocumentOption = @"TextSizeMultiplier";
NSString *const NSTextSizeMultiplierDocumentOption = @"TextSizeMultiplier"; NSAttributedStringDocumentReadingOptionKey NSFileTypeDocumentOption = @"UTI";
NSString *const NSFileTypeDocumentOption = @"UTI";
NSString *const NSPlainTextDocumentType = @"NSPlainText"; NSAttributedStringDocumentType NSPlainTextDocumentType = @"NSPlainText";
NSString *const NSRTFTextDocumentType = @"NSRTF"; NSAttributedStringDocumentType NSRTFTextDocumentType = @"NSRTF";
NSString *const NSRTFDTextDocumentType = @"NSRTFD"; NSAttributedStringDocumentType NSRTFDTextDocumentType = @"NSRTFD";
NSString *const NSHTMLTextDocumentType = @"NSHTML"; NSAttributedStringDocumentType NSHTMLTextDocumentType = @"NSHTML";
NSString *const NSMacSimpleTextDocumentType = @"NSMacSimpleText"; NSAttributedStringDocumentType NSMacSimpleTextDocumentType = @"NSMacSimpleText";
NSString *const NSDocFormatTextDocumentType = @"NSDocFormat"; NSAttributedStringDocumentType NSDocFormatTextDocumentType = @"NSDocFormat";
NSString *const NSWordMLTextDocumentType = @"NSWordML"; NSAttributedStringDocumentType NSWordMLTextDocumentType = @"NSWordML";
NSString *const NSWebArchiveTextDocumentType = @"NSWebArchive"; NSAttributedStringDocumentType NSWebArchiveTextDocumentType = @"NSWebArchive";
NSString *const NSOfficeOpenXMLTextDocumentType = @"NSOfficeOpenXML"; NSAttributedStringDocumentType NSOfficeOpenXMLTextDocumentType = @"NSOfficeOpenXML";
NSString *const NSOpenDocumentTextDocumentType = @"NSOpenDocument"; NSAttributedStringDocumentType NSOpenDocumentTextDocumentType = @"NSOpenDocument";
NSString *const NSTextLayoutSectionOrientation = NSTextLayoutSectionKey NSTextLayoutSectionOrientation = @"NSTextLayoutSectionOrientation";
@"NSTextLayoutSectionOrientation"; NSTextLayoutSectionKey NSTextLayoutSectionRange = @"NSTextLayoutSectionRange";
NSString *const NSTextLayoutSectionRange = @"NSTextLayoutSectionRange";
NSString *const NSCharacterShapeAttributeName = @"NSCharacterShape"; NSAttributedStringKey NSCharacterShapeAttributeName = @"NSCharacterShape";
NSString *const NSUsesScreenFontsDocumentAttribute = @"UsesScreenFonts"; NSAttributedStringKey NSUsesScreenFontsDocumentAttribute = @"UsesScreenFonts";
NSString *const NSTextEffectAttributeName = @"NSTextEffect"; const NSAttributedStringKey NSTextEffectAttributeName = @"NSTextEffect";
NSAttributedStringKey NSWritingDirectionAttributeName = @"NSWritingDirectionAttribute";
NSUInteger NSUnderlineStrikethroughMask = 0x4000; NSUInteger NSUnderlineStrikethroughMask = 0x4000;
NSUInteger NSUnderlineByWordMask = 0x8000; NSUInteger NSUnderlineByWordMask = 0x8000;
@ -157,8 +144,90 @@ NSUInteger NSUnderlineByWordMask = 0x8000;
error: (NSError **) error error: (NSError **) error
{ {
NSUnimplementedMethod(); NSUnimplementedMethod();
NSString *docType = [options objectForKey:NSDocumentTypeDocumentAttribute];
//Infer the document format if not provided
if(docType == nil){
//Extract a prefix from the document to identify the type
//FIXME: use 64 bit ready types and check encoding
char prefix[14];
NSUInteger dataLength = [data length];
if(dataLength < sizeof(prefix))
{
[data getBytes: prefix length: dataLength];
prefix[dataLength] = 0;
}
else
{
[data getBytes: prefix length: sizeof(prefix)];
}
//Use the prefix to determine the document format
// FIXME extend the list
if (strncmp(prefix, "{\\rtf", 5) == 0)
{
docType = NSRTFTextDocumentType;
}
else if (strncasecmp(prefix, "<!doctype html", 14) == 0 ||
strncasecmp(prefix, "<head", 5) == 0 ||
strncasecmp(prefix, "<title", 6) == 0 ||
strncasecmp(prefix, "<html", 5) == 0 ||
strncmp(prefix, "<!--", 4) == 0 ||
strncasecmp(prefix, "<h1", 3) == 0)
{
docType = NSHTMLTextDocumentType;
}
else
{
docType = NSPlainTextDocumentType;
}
}
//Read the document based on its type
//TODO: Implement reading for all types
if([docType isEqual: NSDocFormatTextDocumentType]){
return nil; return nil;
} }
else if([docType isEqual: NSHTMLTextDocumentType]){
NSLog(@"NSAttributedString initFromData - dont know how to parse %@", docType);
return nil;
}
else if([docType isEqual: NSMacSimpleTextDocumentType]){
NSLog(@"NSAttributedString initFromData - dont know how to parse %@", docType);
return nil;
}
else if([docType isEqual: NSOfficeOpenXMLTextDocumentType]){
NSLog(@"NSAttributedString initFromData - dont know how to parse %@", docType);
return nil;
}
else if([docType isEqual: NSOpenDocumentTextDocumentType]){
NSLog(@"NSAttributedString initFromData - dont know how to parse %@", docType);
return nil;
}
else if([docType isEqual: NSPlainTextDocumentType]){
NSLog(@"NSAttributedString initFromData - dont know how to parse %@", docType);
return nil;
}
else if([docType isEqual: NSRTFTextDocumentType]){
return [self initWithRTF: data documentAttributes: attributes];
}
else if([docType isEqual: NSRTFDTextDocumentType]){
NSLog(@"NSAttributedString initFromData - dont know how to parse %@", docType);
return nil;
}
else if([docType isEqual: NSWebArchiveTextDocumentType]){
NSLog(@"NSAttributedString initFromData - dont know how to parse %@", docType);
return nil;
}
else if([docType isEqual: NSWordMLTextDocumentType]){
NSLog(@"NSAttributedString initFromData - dont know how to parse %@", docType);
return nil;
}
else {
return nil;
}
}
- initWithDocFormat: (NSData *) werd - initWithDocFormat: (NSData *) werd
documentAttributes: (NSDictionary **) attributes documentAttributes: (NSDictionary **) attributes
@ -203,6 +272,8 @@ NSUInteger NSUnderlineByWordMask = 0x8000;
} }
- initWithRTF: (NSData *) rtf documentAttributes: (NSDictionary **) attributes { - initWithRTF: (NSData *) rtf documentAttributes: (NSDictionary **) attributes {
*attributes = [NSDictionary dictionaryWithObject: NSRTFTextDocumentType
forKey: NSDocumentTypeDocumentAttribute];
NSAttributedString *string = NSAttributedString *string =
[NSRichTextReader attributedStringWithData: rtf]; [NSRichTextReader attributedStringWithData: rtf];
if (string == nil) { if (string == nil) {
@ -236,8 +307,8 @@ NSUInteger NSUnderlineByWordMask = 0x8000;
documentAttributes: (NSDictionary **) attributes documentAttributes: (NSDictionary **) attributes
error: (NSError **) error error: (NSError **) error
{ {
NSUnimplementedMethod(); NSData *data = [NSData dataWithContentsOfURL: url];
return nil; return [self initWithData: data options: options documentAttributes: attributes error: error];
} }
#pragma mark - #pragma mark -

View File

@ -426,6 +426,10 @@ static int untitled_document_number = 0;
case NSChangeAutosaved: case NSChangeAutosaved:
NSUnimplementedMethod(); NSUnimplementedMethod();
break; break;
case NSChangeRedone:
_changeCount++; //Opposite of Undo - this may be wrong
break;
} }
BOOL edited = [self isDocumentEdited]; BOOL edited = [self isDocumentEdited];
@ -467,6 +471,7 @@ static int untitled_document_number = 0;
if ([self _isSelectorOverridden: @selector(readFromFile:ofType:)]) { if ([self _isSelectorOverridden: @selector(readFromFile:ofType:)]) {
return [self readFromFile: [url path] ofType: type]; return [self readFromFile: [url path] ofType: type];
} else { } else {
NSFileWrapper *fileWrapper = [[[NSFileWrapper alloc] NSFileWrapper *fileWrapper = [[[NSFileWrapper alloc]
initWithPath: [url path]] autorelease]; initWithPath: [url path]] autorelease];
@ -1197,9 +1202,8 @@ static int untitled_document_number = 0;
return self; return self;
} }
- initWithContentsOfURL: (NSURL *) url ofType: (NSString *) type { - (id) initWithContentsOfURL: (NSURL *) url ofType: (NSString *) type {
NSError *error; NSError *error;
[self init]; [self init];
error = nil; error = nil;
@ -1223,6 +1227,7 @@ static int untitled_document_number = 0;
return self; return self;
} }
- (BOOL) loadDataRepresentation: (NSData *) data ofType: (NSString *) type { - (BOOL) loadDataRepresentation: (NSData *) data ofType: (NSString *) type {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
format: @"-[%@ %s]", [self class], sel_getName(_cmd)]; format: @"-[%@ %s]", [self class], sel_getName(_cmd)];
@ -1507,4 +1512,18 @@ static int untitled_document_number = 0;
block(); block();
} }
- (void) saveToURL: (NSURL *) url
ofType: (NSString *) typeName
forSaveOperation: (NSSaveOperationType) saveOperation
completionHandler: (void (^)(NSError *errorOrNil)) completionHandler
{
NSUnimplementedMethod();
}
- (void) autosaveWithImplicitCancellability: (BOOL) autosavingIsImplicitlyCancellable
completionHandler: (void (^)(NSError *errorOrNil)) completionHandler
{
NSUnimplementedMethod();
}
@end @end

View File

@ -30,14 +30,50 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@interface _NSUnsupportedDocument : NSObject @interface _NSUnsupportedDocument : NSObject
- initWithType: (NSString *) type error: (NSError **) error; - (instancetype) initWithType: (NSString *) type error: (NSError **) error;
- (instancetype) initWithContentsOfURL: (NSURL *) url
ofType: (NSString *) typeName
error: (NSError *_Nullable *) outError;
- (id) initWithContentsOfURL: (NSURL *) url ofType: (NSString *) typeName;
- (id) initWithContentsOfFile: (NSString *) absolutePath
ofType: (NSString *) typeName;
@end @end
@implementation _NSUnsupportedDocument @implementation _NSUnsupportedDocument
- initWithType: (NSString *) type error: (NSError **) error { - (instancetype) initWithType: (NSString *) type error: (NSError **) error {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code: NSFeatureUnsupportedError userInfo: nil]; *error = [NSError errorWithDomain: NSCocoaErrorDomain
code: NSFeatureUnsupportedError
userInfo: nil];
[self release];
return nil;
}
- (instancetype) initWithContentsOfURL: (NSURL *) url
ofType: (NSString *) typeName
error: (NSError *_Nullable *) outError
{
if (outError) {
*outError = [NSError errorWithDomain: NSCocoaErrorDomain
code: NSFeatureUnsupportedError
userInfo: nil];
}
[self release];
return nil;
}
- (id) initWithContentsOfURL: (NSURL *) url ofType: (NSString *) typeName {
[self release];
return nil;
}
- (id) initWithContentsOfFile: (NSString *) absolutePath
ofType: (NSString *) typeName
{
[self release];
return nil; return nil;
} }
@ -141,10 +177,15 @@ static NSDocumentController *shared = nil;
} }
- (Class) documentClassForType: (NSString *) type { - (Class) documentClassForType: (NSString *) type {
NSDictionary *info = [self _infoForType: type]; NSString *result = nil;
NSString *result = [info objectForKey: @"NSDocumentClass"]; for (NSDictionary *fileType in _fileTypes) {
if ([type isEqualToString: [fileType objectForKey: @"CFBundleTypeName"]]) {
result = [fileType objectForKey: @"NSDocumentClass"];
break;
}
}
return (result == nil) ? [_NSUnsupportedDocument class] : NSClassFromString(result); return (result == nil) ? nil : NSClassFromString(result);
} }
- (NSArray *) fileExtensionsFromType: (NSString *) type { - (NSArray *) fileExtensionsFromType: (NSString *) type {
@ -168,13 +209,13 @@ static NSDocumentController *shared = nil;
- (NSString *) typeFromFileExtension: (NSString *) extension { - (NSString *) typeFromFileExtension: (NSString *) extension {
extension = [extension lowercaseString]; extension = [extension lowercaseString];
for (NSDictionary *fileType in _fileTypes) for (NSDictionary *fileType in _fileTypes)
for (NSString *name in for (NSString *name in
[fileType objectForKey: @"CFBundleTypeExtensions"]) [fileType objectForKey: @"CFBundleTypeExtensions"]) {
if ([[name lowercaseString] isEqual: extension] || if ([[name lowercaseString] isEqual: extension] ||
[name isEqual: @"*"]) [name isEqual: @"*"])
return [fileType objectForKey: @"CFBundleTypeName"]; return [fileType objectForKey: @"CFBundleTypeName"];
}
return nil; return nil;
} }
@ -259,7 +300,21 @@ static NSDocumentController *shared = nil;
if (extension == nil) if (extension == nil)
return nil; return nil;
return [self typeFromFileExtension: extension]; NSString *UTI;
BOOL success = [url getResourceValue: &UTI
forKey: NSURLTypeIdentifierKey
error: error];
if (!success) {
return nil;
}
for(NSDictionary *fileType in _fileTypes) {
if ([[fileType objectForKey: @"LSItemContentTypes"] containsObject: UTI]) {
return [fileType objectForKey: @"CFBundleTypeName"];
}
}
return nil;
} }
- makeDocumentWithContentsOfFile: (NSString *) path ofType: (NSString *) type { - makeDocumentWithContentsOfFile: (NSString *) path ofType: (NSString *) type {
@ -281,7 +336,6 @@ static NSDocumentController *shared = nil;
result = [[[class alloc] initWithContentsOfURL: url result = [[[class alloc] initWithContentsOfURL: url
ofType: type] autorelease]; ofType: type] autorelease];
return result; return result;
} }
@ -367,7 +421,6 @@ static NSDocumentController *shared = nil;
- openUntitledDocumentAndDisplay: (BOOL) display error: (NSError **) error { - openUntitledDocumentAndDisplay: (BOOL) display error: (NSError **) error {
NSString *type = [self defaultType]; NSString *type = [self defaultType];
/* Cocoa documentation says: /* Cocoa documentation says:
"For backward binary compatibility with Mac OS X v10.3 and earlier, "For backward binary compatibility with Mac OS X v10.3 and earlier,
the default implementation of this method instead invokes the default implementation of this method instead invokes
@ -430,13 +483,20 @@ static NSDocumentController *shared = nil;
NSDocument *result = [self documentForURL: url]; NSDocument *result = [self documentForURL: url];
if (result == nil) { if (result == nil) {
NSString *extension = [[url path] pathExtension]; NSError *type_error = nil;
NSString *type = [self typeFromFileExtension: extension]; NSString *type = [self typeForContentsOfURL: url
error: &type_error];
if (type_error) {
if (error) {
*error = type_error;
}
return result;
}
result = [self makeDocumentWithContentsOfURL: url result = [self makeDocumentWithContentsOfURL: url
ofType: type ofType: type
error: error]; error: error];
if (result != nil) { if (result != nil) {
[self addDocument: result]; [self addDocument: result];
[result makeWindowControllers]; [result makeWindowControllers];

View File

@ -203,4 +203,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
[self endEditing]; [self endEditing];
} }
- (BOOL) readFromURL: (NSURL *) url
options: (NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *) opts
documentAttributes: (NSDictionary<NSAttributedStringDocumentAttributeKey, id> *_Nullable *) dict
error: (NSError *_Nullable *) error
{
NSAttributedString *str = [NSAttributedString alloc];
str = [str initWithURL: url
options: opts
documentAttributes: dict
error: error];
if (str == nil) {
return NO;
}
[self setAttributedString: str];
[str release];
return YES;
}
@end @end

View File

@ -128,9 +128,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
} }
- (void) setTabStops: (NSArray *) tabStops { - (void) setTabStops: (NSArray *) tabStops {
tabStops = [tabStops copy]; if (tabStops != _tabStops) {
[_tabStops release]; [_tabStops removeAllObjects];
_tabStops = tabStops; [_tabStops addObjectsFromArray: tabStops];
[_tabStops sortUsingSelector: @selector(compare:)];
}
}
- (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 {
[_tabStops removeObject: tabStop];
} }
- (void) setHyphenationFactor: (float) factor { - (void) setHyphenationFactor: (float) factor {

View File

@ -34,6 +34,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
return shared; return shared;
} }
+ (NSWritingDirection) defaultWritingDirectionForLanguage: (NSString *) languageName {
NSUnimplementedMethod();
return NSWritingDirectionNatural;
}
+ (NSArray *) _defaultTabStops { + (NSArray *) _defaultTabStops {
static NSArray *shared = nil; static NSArray *shared = nil;
@ -69,7 +74,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
_lineHeightMultiple = 0; _lineHeightMultiple = 0;
_lineSpacing = 0; _lineSpacing = 0;
_defaultTabInterval = 0; _defaultTabInterval = 0;
_tabStops = [[[self class] _defaultTabStops] retain]; _tabStops = [[[self class] _defaultTabStops] mutableCopy];
_hyphenationFactor = 0; _hyphenationFactor = 0;
_tighteningFactorForTruncation = 0; _tighteningFactorForTruncation = 0;
} }

View File

@ -86,6 +86,20 @@ static Class _rulerViewClass = nil;
return contentSize; return contentSize;
} }
+ (NSSize) frameSizeForContentSize: (NSSize) cSize
horizontalScrollerClass: (Class) horizontalScrollerClass
verticalScrollerClass: (Class) verticalScrollerClass
borderType: (NSBorderType) type
controlSize: (NSControlSize) controlSize
scrollerStyle: (NSScrollerStyle) scrollerStyle
{
NSUnimplementedMethod();
return [self frameSizeForContentSize: cSize
hasHorizontalScroller: YES
hasVerticalScroller: YES
borderType: type];
}
+ (NSSize) contentSizeForFrameSize: (NSSize) frameSize + (NSSize) contentSizeForFrameSize: (NSSize) frameSize
hasHorizontalScroller: (BOOL) hasHorizontalScroller hasHorizontalScroller: (BOOL) hasHorizontalScroller
hasVerticalScroller: (BOOL) hasVerticalScroller hasVerticalScroller: (BOOL) hasVerticalScroller
@ -120,6 +134,16 @@ static Class _rulerViewClass = nil;
return frameSize; return frameSize;
} }
+ (NSSize) contentSizeForFrameSize: (NSSize) fSize
horizontalScrollerClass: (Class) horizontalScrollerClass
verticalScrollerClass: (Class) verticalScrollerClass
borderType: (NSBorderType) type
controlSize: (NSControlSize) controlSize
scrollerStyle: (NSScrollerStyle) scrollerStyle
{
NSUnimplementedMethod();
}
+ (void) setRulerViewClass: (Class) class { + (void) setRulerViewClass: (Class) class {
_rulerViewClass = class; _rulerViewClass = class;
} }
@ -614,6 +638,22 @@ static Class _rulerViewClass = nil;
return _documentCursor; return _documentCursor;
} }
- (CGFloat) magnification {
return _magnification;
}
- (CGFloat) minMagnification {
return _minMagnification;
}
- (CGFloat) maxMagnification {
return _maxMagnification;
}
- (BOOL) allowsMagnification {
return _allowsMagnification;
}
- (void) setDocumentView: (NSView *) view { - (void) setDocumentView: (NSView *) view {
[_clipView setDocumentView: view]; [_clipView setDocumentView: view];
[self reflectScrolledClipView: _clipView]; [self reflectScrolledClipView: _clipView];
@ -779,6 +819,38 @@ static Class _rulerViewClass = nil;
// FIXME: tile or hide/show scrollers? // FIXME: tile or hide/show scrollers?
} }
- (void) setMagnification: (CGFloat) value {
if (value == _magnification)
return;
_magnification = value;
if (_magnification < _minMagnification)
_magnification = _minMagnification;
if (_magnification < _maxMagnification)
_magnification = _maxMagnification;
// TODO: calculate new bounds and call setBounds
}
- (void) setMinMagnification: (CGFloat) value {
_minMagnification = value;
if (_minMagnification > _magnification)
[self setMagnification: value];
}
- (void) setMaxMagnification: (CGFloat) value {
_maxMagnification = value;
if (_maxMagnification < _magnification)
[self setMagnification: value];
}
- (void) setAllowsMagnification: (BOOL) value {
_allowsMagnification = value;
}
- (void) tile { - (void) tile {
NSRect frame; NSRect frame;

View File

@ -34,6 +34,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
return [[NSDisplay currentDisplay] scrollerWidth]; return [[NSDisplay currentDisplay] scrollerWidth];
} }
+ (NSScrollerStyle) preferredScrollerStyle {
NSUnimplementedMethod();
}
/* OS X has a global default "AppleScrollBarVariant" with the values: Single, /* OS X has a global default "AppleScrollBarVariant" with the values: Single,
DoubleMin, DoubleMax, and DoubleBoth This controls the default position of the DoubleMin, DoubleMax, and DoubleBoth This controls the default position of the
scroller. This should be controlling the positioning. scroller. This should be controlling the positioning.
@ -141,6 +144,11 @@ static NSAppleScrollBarVariant appleScrollBarVariant(NSScroller *self) {
return _controlSize; return _controlSize;
} }
- (NSScrollerStyle) scrollerStyle {
return _scrollerStyle;
}
- (void) setFloatValue: (float) zeroToOneValue - (void) setFloatValue: (float) zeroToOneValue
knobProportion: (CGFloat) zeroToOneKnob knobProportion: (CGFloat) zeroToOneKnob
{ {
@ -185,6 +193,10 @@ static NSAppleScrollBarVariant appleScrollBarVariant(NSScroller *self) {
[self setNeedsDisplay: YES]; [self setNeedsDisplay: YES];
} }
- (void) setScrollerStyle: (NSScrollerStyle) style {
_scrollerStyle = style;
}
- (NSRect) frameOfDecrementPage { - (NSRect) frameOfDecrementPage {
NSRect knobSlot = [self rectForPart: NSScrollerKnobSlot]; NSRect knobSlot = [self rectForPart: NSScrollerKnobSlot];
NSRect knob = [self rectForPart: NSScrollerKnob]; NSRect knob = [self rectForPart: NSScrollerKnob];

View File

@ -30,7 +30,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSTypesetter.h> #import <AppKit/NSTypesetter.h>
#import <AppKit/NSWindow.h> #import <AppKit/NSWindow.h>
#import <Foundation/NSRangeEntries.h>
#import <AppKit/NSAttributedString.h> #import <AppKit/NSAttributedString.h>
#import <AppKit/NSColor.h> #import <AppKit/NSColor.h>
#import <AppKit/NSGraphics.h> #import <AppKit/NSGraphics.h>
@ -39,6 +38,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <ApplicationServices/ApplicationServices.h> #import <ApplicationServices/ApplicationServices.h>
#import <Foundation/NSKeyedArchiver.h> #import <Foundation/NSKeyedArchiver.h>
#import <Foundation/NSRaiseException.h> #import <Foundation/NSRaiseException.h>
#import <Foundation/NSRangeEntries.h>
#import "NSBidiHelper.h" #import "NSBidiHelper.h"
#import "NSRulerMarker+NSTextExtensions.h" #import "NSRulerMarker+NSTextExtensions.h"
@ -177,11 +177,17 @@ static inline NSGlyphFragment *fragmentAtGlyphIndex(NSLayoutManager *self,
} }
- (NSTextView *) firstTextView { - (NSTextView *) firstTextView {
return [[_textContainers objectAtIndex: 0] textView]; for (NSTextContainer *container in _textContainers) {
NSTextView *textView = [container textView];
if (textView) {
return textView;
}
}
return nil;
} }
- (NSTextView *) textViewForBeginningOfSelection { - (NSTextView *) textViewForBeginningOfSelection {
return [[_textContainers objectAtIndex: 0] textView]; return [self firstTextView];
} }
- (BOOL) layoutManagerOwnsFirstResponderInWindow: (NSWindow *) window { - (BOOL) layoutManagerOwnsFirstResponderInWindow: (NSWindow *) window {
@ -726,6 +732,10 @@ static inline NSGlyphFragment *fragmentAtGlyphIndex(NSLayoutManager *self,
return _extraLineFragmentTextContainer; return _extraLineFragmentTextContainer;
} }
- (BOOL) allowsNonContiguousLayout {
return _allowsNonContiguousLayout;
}
- (void) setTextContainer: (NSTextContainer *) container - (void) setTextContainer: (NSTextContainer *) container
forGlyphRange: (NSRange) glyphRange forGlyphRange: (NSRange) glyphRange
{ {
@ -1374,7 +1384,8 @@ static inline void _appendRectToCache(NSLayoutManager *self, NSRect rect) {
NSRange intersect; NSRange intersect;
if (remainder.length > 0) if (remainder.length > 0)
intersect = NSIntersectionRange(remainder, range); intersect = NSIntersectionRange(remainder, range);
else // NSIntersectionRange's returned location is undefined for 0-length ranges else // NSIntersectionRange's returned location is undefined for
// 0-length ranges
intersect = NSMakeRange(remainder.location, 0); intersect = NSMakeRange(remainder.location, 0);
#if DEBUG_rectArrayForGlyphRange_withinSelectedGlyphRange_inTextContainer_rectCount #if DEBUG_rectArrayForGlyphRange_withinSelectedGlyphRange_inTextContainer_rectCount
@ -2909,4 +2920,9 @@ static inline void _appendRectToCache(NSLayoutManager *self, NSRect rect) {
{ {
return nil; return nil;
} }
- (void) setAllowsNonContiguousLayout: (BOOL) value {
_allowsNonContiguousLayout = value;
NSUnimplementedMethod();
}
@end @end

View File

@ -189,6 +189,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
- (void) setLayoutManager: (NSLayoutManager *) layoutManager { - (void) setLayoutManager: (NSLayoutManager *) layoutManager {
_layoutManager = layoutManager; _layoutManager = layoutManager;
[_textView _setTextStorage: [_layoutManager textStorage]];
} }
- (void) replaceLayoutManager: (NSLayoutManager *) layoutManager { - (void) replaceLayoutManager: (NSLayoutManager *) layoutManager {

View File

@ -136,4 +136,20 @@ NSString *NSTabColumnTerminatorsAttributeName =
return self.location == other.location && return self.location == other.location &&
self.tabStopType == other.tabStopType; 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 @end

View File

@ -143,6 +143,37 @@ NSString *const NSAllRomanInputSourcesLocaleIdentifier =
NSUnimplementedMethod(); NSUnimplementedMethod();
} }
- (void) _setTextStorage: (NSTextStorage *) storage {
if (_ownsTextStorage)
[_textStorage release];
_textStorage = storage;
_ownsTextStorage = NO;
NSMutableDictionary *typingAttributes =
[[_textStorage attributesAtIndex: 0
effectiveRange: NULL] mutableCopy];
if (![typingAttributes objectForKey: NSFontAttributeName]) {
[typingAttributes setObject: _font forKey: NSFontAttributeName];
}
if (![typingAttributes objectForKey: NSForegroundColorAttributeName]) {
[typingAttributes setObject: _textColor
forKey: NSForegroundColorAttributeName];
}
[_typingAttributes release];
_typingAttributes = typingAttributes;
[_defaultParagraphStyle release];
if ([typingAttributes objectForKey: NSParagraphStyleAttributeName]) {
_defaultParagraphStyle = [[typingAttributes
objectForKey: NSParagraphStyleAttributeName] copy];
} else {
_defaultParagraphStyle =
[[NSParagraphStyle defaultParagraphStyle] copy];
}
}
- initWithCoder: (NSCoder *) coder { - initWithCoder: (NSCoder *) coder {
[super initWithCoder: coder]; [super initWithCoder: coder];
@ -240,8 +271,6 @@ NSString *const NSAllRomanInputSourcesLocaleIdentifier =
- initWithFrame: (NSRect) frame textContainer: (NSTextContainer *) container { - initWithFrame: (NSRect) frame textContainer: (NSTextContainer *) container {
[super initWithFrame: frame]; [super initWithFrame: frame];
_textStorage = [[container layoutManager] textStorage];
_ownsTextStorage = NO;
_textContainer = [container retain]; _textContainer = [container retain];
[_textContainer setTextView: self]; [_textContainer setTextView: self];
_textContainerInset = NSMakeSize(0, 0); _textContainerInset = NSMakeSize(0, 0);
@ -263,26 +292,6 @@ NSString *const NSAllRomanInputSourcesLocaleIdentifier =
_selectedRanges = [[NSMutableArray alloc] init]; _selectedRanges = [[NSMutableArray alloc] init];
[_selectedRanges addObject: [NSValue valueWithRange: NSMakeRange(0, 0)]]; [_selectedRanges addObject: [NSValue valueWithRange: NSMakeRange(0, 0)]];
NSMutableDictionary *typingAttributes =
[[_textStorage attributesAtIndex: 0
effectiveRange: NULL] mutableCopy];
if (![typingAttributes objectForKey: NSFontAttributeName]) {
[typingAttributes setObject: _font forKey: NSFontAttributeName];
}
if (![typingAttributes objectForKey: NSForegroundColorAttributeName]) {
[typingAttributes setObject: _textColor
forKey: NSForegroundColorAttributeName];
}
_typingAttributes = typingAttributes;
if ([typingAttributes objectForKey: NSParagraphStyleAttributeName]) {
_defaultParagraphStyle = [[typingAttributes
objectForKey: NSParagraphStyleAttributeName] copy];
} else {
_defaultParagraphStyle =
[[NSParagraphStyle defaultParagraphStyle] copy];
}
_rangeForUserCompletion = NSMakeRange(NSNotFound, 0); _rangeForUserCompletion = NSMakeRange(NSNotFound, 0);
_selectedTextAttributes = [[NSDictionary _selectedTextAttributes = [[NSDictionary
dictionaryWithObjectsAndKeys: [NSColor selectedTextColor], dictionaryWithObjectsAndKeys: [NSColor selectedTextColor],
@ -291,9 +300,12 @@ NSString *const NSAllRomanInputSourcesLocaleIdentifier =
NSBackgroundColorAttributeName, nil] NSBackgroundColorAttributeName, nil]
retain]; retain];
[self _setTextStorage: [[container layoutManager] textStorage]];
[self setBoundsOrigin: NSMakePoint(-_textContainerInset.width, [self setBoundsOrigin: NSMakePoint(-_textContainerInset.width,
-_textContainerInset.height)]; -_textContainerInset.height)];
[self configureMenu]; [self configureMenu];
[self registerForDraggedTypes: [NSArray [self registerForDraggedTypes: [NSArray
arrayWithObjects: NSRTFPboardType, arrayWithObjects: NSRTFPboardType,
NSStringPboardType, NSStringPboardType,
@ -3389,9 +3401,7 @@ NSString *const NSAllRomanInputSourcesLocaleIdentifier =
- (void) _continuousSpellCheckWithInvalidatedRange: (NSRange) invalidatedRange { - (void) _continuousSpellCheckWithInvalidatedRange: (NSRange) invalidatedRange {
NSString *string = [self string]; NSString *string = [self string];
NSUInteger start, end; NSUInteger start, end;
// TODO, truncate invalidated range to string size if needed // TODO, truncate invalidated range to string size if needed
// round range to nearest paragraphs // round range to nearest paragraphs
[string getParagraphStart: &start [string getParagraphStart: &start
@ -3433,10 +3443,8 @@ NSString *const NSAllRomanInputSourcesLocaleIdentifier =
} }
- (void) _continuousSpellCheck { - (void) _continuousSpellCheck {
[self _continuousSpellCheckWithInvalidatedRange: NSMakeRange( NSRange invalidatedRange = NSMakeRange(0, [[self string] length]);
0, [self _continuousSpellCheckWithInvalidatedRange: invalidatedRange];
[[self string]
length])];
} }
- (void) checkSpelling: sender { - (void) checkSpelling: sender {
@ -3630,6 +3638,22 @@ NSString *const NSAllRomanInputSourcesLocaleIdentifier =
NSUnimplementedMethod(); NSUnimplementedMethod();
} }
- (BOOL) smartInsertDeleteEnabled {
return _smartInsertDeleteEnabled;
}
- (void) setSmartInsertDeleteEnabled: (BOOL) boolForKey {
_smartInsertDeleteEnabled = boolForKey;
}
- (BOOL) allowsDocumentBackgroundColorChange {
return _allowsDocumentBackgroundColorChange;
}
- (void) setAllowsDocumentBackgroundColorChange: (BOOL) value {
_allowsDocumentBackgroundColorChange = value;
}
- (void) setSpellingState: (NSInteger) value range: (NSRange) characterRange { - (void) setSpellingState: (NSInteger) value range: (NSRange) characterRange {
[[self layoutManager] [[self layoutManager]
addTemporaryAttribute: NSSpellingStateAttributeName addTemporaryAttribute: NSSpellingStateAttributeName
@ -3957,5 +3981,109 @@ NSString *const NSAllRomanInputSourcesLocaleIdentifier =
NSUnimplementedMethod(); NSUnimplementedMethod();
return self; return self;
} }
- (NSTextLayoutOrientation) layoutOrientation {
NSUnimplementedMethod();
return _layoutOrientation;
}
- (void) setLayoutOrientation: (NSTextLayoutOrientation) orientation {
_layoutOrientation = orientation;
NSUnimplementedMethod();
}
- (BOOL) isIncrementalSearchingEnabled {
NSUnimplementedMethod();
return _incrementalSearchingEnabled;
}
- (BOOL) usesFindBar {
NSUnimplementedMethod();
return _usesFindBar;
}
- (BOOL) usesInspectorBar {
NSUnimplementedMethod();
return _usesInspectorBar;
}
- (void) setIncrementalSearchingEnabled: (BOOL) value {
NSUnimplementedMethod();
_incrementalSearchingEnabled = value;
}
- (void) setUsesFindBar: (BOOL) value {
NSUnimplementedMethod();
_usesFindBar = value;
}
- (void) setUsesInspectorBar: (BOOL) value {
NSUnimplementedMethod();
_usesInspectorBar = value;
}
- (BOOL) isGrammarCheckingEnabled {
NSUnimplementedMethod();
return _grammarCheckingEnabled;
}
- (BOOL) isAutomaticQuoteSubstitutionEnabled {
NSUnimplementedMethod();
return _automaticQuoteSubstitutionEnabled;
}
- (BOOL) isAutomaticDashSubstitutionEnabled {
NSUnimplementedMethod();
return _automaticDashSubstitutionEnabled;
}
- (BOOL) isAutomaticLinkDetectionEnabled {
NSUnimplementedMethod();
return _automaticLinkDetectionEnabled;
}
- (BOOL) isAutomaticDataDetectionEnabled {
NSUnimplementedMethod();
return _automaticDataDetectionEnabled;
}
- (BOOL) isAutomaticTextReplacementEnabled {
NSUnimplementedMethod();
return _automaticTextReplacementEnabled;
}
- (void) setGrammarCheckingEnabled: (BOOL) value {
NSUnimplementedMethod();
_grammarCheckingEnabled = value;
}
- (void) setAutomaticQuoteSubstitutionEnabled: (BOOL) value {
NSUnimplementedMethod();
_automaticQuoteSubstitutionEnabled = value;
}
- (void) setAutomaticDashSubstitutionEnabled: (BOOL) value {
NSUnimplementedMethod();
_automaticDashSubstitutionEnabled = value;
}
- (void) setAutomaticLinkDetectionEnabled: (BOOL) value {
NSUnimplementedMethod();
_automaticLinkDetectionEnabled = value;
}
- (void) setAutomaticDataDetectionEnabled: (BOOL) value {
NSUnimplementedMethod();
_automaticDataDetectionEnabled = value;
}
- (void) setAutomaticTextReplacementEnabled: (BOOL) value {
NSUnimplementedMethod();
_automaticTextReplacementEnabled = value;
}
// Is defined in NSText but throws an NSInvalidAbstractInvocation Exception
- (void) setImportsGraphics: (BOOL) value {
NSUnimplementedMethod();
}
@end @end

View File

@ -592,10 +592,10 @@ static NSDictionary *modeInfoToDictionary(const XRRModeInfo *mi, int depth) {
if ([colorName isEqual: @"windowFrameColor"]) if ([colorName isEqual: @"windowFrameColor"])
return [NSColor lightGrayColor]; return [NSColor lightGrayColor];
if ([colorName isEqual: @"selectedTextBackgroundColor"]) if ([colorName isEqual: @"selectedTextBackgroundColor"])
return [NSColor colorWithCalibratedRed: 0x33 return [NSColor colorWithCalibratedRed: 0.20f
green: 0x8f green: 0.55f
blue: 0xff blue: 1.00f
alpha: 1.0f]; alpha: 1.00f];
NSLog(@"missing color for %@", colorName); NSLog(@"missing color for %@", colorName);
return [NSColor redColor]; return [NSColor redColor];

View File

@ -24,95 +24,112 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@class NSFont, NSColor, NSParagraphStyle, NSTextAttachment, NSFileWrapper, @class NSFont, NSColor, NSParagraphStyle, NSTextAttachment, NSFileWrapper,
NSTextList, NSTextBlock, NSTextTable; NSTextList, NSTextBlock, NSTextTable;
APPKIT_EXPORT NSString *const NSFontAttributeName; typedef NSString *NSAttributedStringDocumentReadingOptionKey;
APPKIT_EXPORT NSString *const NSParagraphStyleAttributeName; typedef NSString *NSAttributedStringDocumentAttributeKey;
APPKIT_EXPORT NSString *const NSForegroundColorAttributeName; typedef NSString *NSAttributedStringDocumentType;
APPKIT_EXPORT NSString *const NSBackgroundColorAttributeName; typedef NSString *NSTextLayoutSectionKey;
APPKIT_EXPORT NSString *const NSUnderlineStyleAttributeName; typedef NSString *NSAttributedStringKey;
APPKIT_EXPORT NSString *const NSUnderlineColorAttributeName;
APPKIT_EXPORT NSString *const NSAttachmentAttributeName;
APPKIT_EXPORT NSString *const NSKernAttributeName;
APPKIT_EXPORT NSString *const NSLigatureAttributeName;
APPKIT_EXPORT NSString *const NSStrikethroughStyleAttributeName;
APPKIT_EXPORT NSString *const NSStrikethroughColorAttributeName;
APPKIT_EXPORT NSString *const NSObliquenessAttributeName;
APPKIT_EXPORT NSString *const NSStrokeWidthAttributeName;
APPKIT_EXPORT NSString *const NSStrokeColorAttributeName;
APPKIT_EXPORT NSString *const NSBaselineOffsetAttributeName;
APPKIT_EXPORT NSString *const NSSuperscriptAttributeName;
APPKIT_EXPORT NSString *const NSLinkAttributeName;
APPKIT_EXPORT NSString *const NSShadowAttributeName;
APPKIT_EXPORT NSString *const NSExpansionAttributeName;
APPKIT_EXPORT NSString *const NSCursorAttributeName;
APPKIT_EXPORT NSString *const NSToolTipAttributeName;
APPKIT_EXPORT NSString *const NSSpellingStateAttributeName; // The following constants are *not* declared as `const` in Apple's AppKit (they are located in __data)
APPKIT_EXPORT NSAttributedStringKey NSFontAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSParagraphStyleAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSForegroundColorAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSBackgroundColorAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSUnderlineStyleAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSUnderlineColorAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSAttachmentAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSKernAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSLigatureAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSStrikethroughStyleAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSStrikethroughColorAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSObliquenessAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSStrokeWidthAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSStrokeColorAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSBaselineOffsetAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSSuperscriptAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSLinkAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSShadowAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSExpansionAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSCursorAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSToolTipAttributeName;
APPKIT_EXPORT NSString *const NSDocumentTypeDocumentAttribute; // The following constant is *not* declared as `const` in Apple's AppKit (they are located in __data)
APPKIT_EXPORT NSString *const NSConvertedDocumentAttribute; APPKIT_EXPORT NSAttributedStringKey NSSpellingStateAttributeName;
APPKIT_EXPORT NSString *const NSFileTypeDocumentAttribute;
APPKIT_EXPORT NSString *const NSTitleDocumentAttribute;
APPKIT_EXPORT NSString *const NSCompanyDocumentAttribute;
APPKIT_EXPORT NSString *const NSCopyrightDocumentAttribute;
APPKIT_EXPORT NSString *const NSSubjectDocumentAttribute;
APPKIT_EXPORT NSString *const NSAuthorDocumentAttribute;
APPKIT_EXPORT NSString *const NSKeywordsDocumentAttribute;
APPKIT_EXPORT NSString *const NSCommentDocumentAttribute;
APPKIT_EXPORT NSString *const NSEditorDocumentAttribute;
APPKIT_EXPORT NSString *const NSCreationTimeDocumentAttribute;
APPKIT_EXPORT NSString *const NSModificationTimeDocumentAttribute;
APPKIT_EXPORT NSString *const NSManagerDocumentAttribute;
APPKIT_EXPORT NSString *const NSCategoryDocumentAttribute;
APPKIT_EXPORT NSString *const NSAppearanceDocumentAttribute;
APPKIT_EXPORT NSString *const NSCharacterEncodingDocumentAttribute;
APPKIT_EXPORT NSString *const NSDefaultAttributesDocumentAttribute;
APPKIT_EXPORT NSString *const NSPaperSizeDocumentAttribute;
APPKIT_EXPORT NSString *const NSLeftMarginDocumentAttribute;
APPKIT_EXPORT NSString *const NSRightMarginDocumentAttribute;
APPKIT_EXPORT NSString *const NSTopMarginDocumentAttribute;
APPKIT_EXPORT NSString *const NSBottomMarginDocumentAttribute;
APPKIT_EXPORT NSString *const NSViewSizeDocumentAttribute;
APPKIT_EXPORT NSString *const NSViewZoomDocumentAttribute;
APPKIT_EXPORT NSString *const NSViewModeDocumentAttribute;
APPKIT_EXPORT NSString *const NSReadOnlyDocumentAttribute;
APPKIT_EXPORT NSString *const NSBackgroundColorDocumentAttribute;
APPKIT_EXPORT NSString *const NSHyphenationFactorDocumentAttribute;
APPKIT_EXPORT NSString *const NSDefaultTabIntervalDocumentAttribute;
APPKIT_EXPORT NSString *const NSTextLayoutSectionsAttribute;
APPKIT_EXPORT NSString *const NSExcludedElementsDocumentAttribute;
APPKIT_EXPORT NSString *const NSTextEncodingNameDocumentAttribute;
APPKIT_EXPORT NSString *const NSPrefixSpacesDocumentAttribute;
APPKIT_EXPORT NSString *const NSDocumentTypeDocumentOption; // The following constants are *not* declared as `const` in Apple's AppKit (they are located in __data)
APPKIT_EXPORT NSString *const NSDefaultAttributesDocumentOption; APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSDocumentTypeDocumentAttribute;
APPKIT_EXPORT NSString *const NSCharacterEncodingDocumentOption; APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSConvertedDocumentAttribute;
APPKIT_EXPORT NSString *const NSTextEncodingNameDocumentOption; APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSFileTypeDocumentAttribute;
APPKIT_EXPORT NSString *const NSBaseURLDocumentOption; APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSTitleDocumentAttribute;
APPKIT_EXPORT NSString *const NSTimeoutDocumentOption; APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSCompanyDocumentAttribute;
APPKIT_EXPORT NSString *const NSWebPreferencesDocumentOption; APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSCopyrightDocumentAttribute;
APPKIT_EXPORT NSString *const NSWebResourceLoadDelegateDocumentOption; APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSSubjectDocumentAttribute;
APPKIT_EXPORT NSString *const NSTextSizeMultiplierDocumentOption; APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSAuthorDocumentAttribute;
APPKIT_EXPORT NSString *const NSFileTypeDocumentOption; APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSKeywordsDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSCommentDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSEditorDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSCreationTimeDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSModificationTimeDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSManagerDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSCategoryDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSAppearanceDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSCharacterEncodingDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSDefaultAttributesDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSPaperSizeDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSLeftMarginDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSRightMarginDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSTopMarginDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSBottomMarginDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSViewSizeDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSViewZoomDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSViewModeDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSReadOnlyDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSBackgroundColorDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSHyphenationFactorDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSDefaultTabIntervalDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSTextLayoutSectionsAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSExcludedElementsDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSTextEncodingNameDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSPrefixSpacesDocumentAttribute;
APPKIT_EXPORT NSAttributedStringDocumentAttributeKey NSCocoaVersionDocumentAttribute;
APPKIT_EXPORT NSString *const NSPlainTextDocumentType; // The following constants are *not* declared as `const` in Apple's AppKit (they are located in __data)
APPKIT_EXPORT NSString *const NSRTFTextDocumentType; APPKIT_EXPORT NSAttributedStringDocumentReadingOptionKey NSDocumentTypeDocumentOption;
APPKIT_EXPORT NSString *const NSRTFDTextDocumentType; APPKIT_EXPORT NSAttributedStringDocumentReadingOptionKey NSDefaultAttributesDocumentOption;
APPKIT_EXPORT NSString *const NSHTMLTextDocumentType; APPKIT_EXPORT NSAttributedStringDocumentReadingOptionKey NSCharacterEncodingDocumentOption;
APPKIT_EXPORT NSString *const NSMacSimpleTextDocumentType; APPKIT_EXPORT NSAttributedStringDocumentReadingOptionKey NSTextEncodingNameDocumentOption;
APPKIT_EXPORT NSString *const NSDocFormatTextDocumentType; APPKIT_EXPORT NSAttributedStringDocumentReadingOptionKey NSBaseURLDocumentOption;
APPKIT_EXPORT NSString *const NSWordMLTextDocumentType; APPKIT_EXPORT NSAttributedStringDocumentReadingOptionKey NSTimeoutDocumentOption;
APPKIT_EXPORT NSString *const NSWebArchiveTextDocumentType; APPKIT_EXPORT NSAttributedStringDocumentReadingOptionKey NSWebPreferencesDocumentOption;
APPKIT_EXPORT NSString *const NSOfficeOpenXMLTextDocumentType; APPKIT_EXPORT NSAttributedStringDocumentReadingOptionKey NSWebResourceLoadDelegateDocumentOption;
APPKIT_EXPORT NSString *const NSOpenDocumentTextDocumentType; APPKIT_EXPORT NSAttributedStringDocumentReadingOptionKey NSTextSizeMultiplierDocumentOption;
APPKIT_EXPORT NSAttributedStringDocumentReadingOptionKey NSFileTypeDocumentOption;
APPKIT_EXPORT NSString *const NSTextLayoutSectionOrientation; // The following constants are *not* declared as `const` in Apple's AppKit (they are located in __data)
APPKIT_EXPORT NSString *const NSTextLayoutSectionRange; APPKIT_EXPORT NSAttributedStringDocumentType NSPlainTextDocumentType;
APPKIT_EXPORT NSAttributedStringDocumentType NSRTFTextDocumentType;
APPKIT_EXPORT NSAttributedStringDocumentType NSRTFDTextDocumentType;
APPKIT_EXPORT NSAttributedStringDocumentType NSHTMLTextDocumentType;
APPKIT_EXPORT NSAttributedStringDocumentType NSMacSimpleTextDocumentType;
APPKIT_EXPORT NSAttributedStringDocumentType NSDocFormatTextDocumentType;
APPKIT_EXPORT NSAttributedStringDocumentType NSWordMLTextDocumentType;
APPKIT_EXPORT NSAttributedStringDocumentType NSWebArchiveTextDocumentType;
APPKIT_EXPORT NSAttributedStringDocumentType NSOfficeOpenXMLTextDocumentType;
APPKIT_EXPORT NSAttributedStringDocumentType NSOpenDocumentTextDocumentType;
APPKIT_EXPORT NSString *const NSCharacterShapeAttributeName; // The following constants are *not* declared as `const` in Apple's AppKit (they are located in __data)
APPKIT_EXPORT NSString *const NSUsesScreenFontsDocumentAttribute; APPKIT_EXPORT NSTextLayoutSectionKey NSTextLayoutSectionOrientation;
APPKIT_EXPORT NSTextLayoutSectionKey NSTextLayoutSectionRange;
APPKIT_EXPORT NSString *const NSTextEffectAttributeName; // The following constants are *not* declared as `const` in Apple's AppKit (they are located in __data)
APPKIT_EXPORT NSAttributedStringKey NSCharacterShapeAttributeName;
APPKIT_EXPORT NSAttributedStringKey NSUsesScreenFontsDocumentAttribute;
APPKIT_EXPORT const NSAttributedStringKey NSTextEffectAttributeName;
// The following constant is *not* declared as `const` in Apple's AppKit (they are located in __data)
APPKIT_EXPORT NSAttributedStringKey NSWritingDirectionAttributeName;
// The following constants are *not* declared as `const` in Apple's AppKit (they are located in __data)
APPKIT_EXPORT NSUInteger NSUnderlineStrikethroughMask; APPKIT_EXPORT NSUInteger NSUnderlineStrikethroughMask;
APPKIT_EXPORT NSUInteger NSUnderlineByWordMask; APPKIT_EXPORT NSUInteger NSUnderlineByWordMask;
@ -239,6 +256,13 @@ enum {
- (NSRect) boundingRectWithSize: (NSSize) size - (NSRect) boundingRectWithSize: (NSSize) size
options: (NSStringDrawingOptions) options; options: (NSStringDrawingOptions) options;
#pragma mark -
#pragma mark Getting Attribute Data
- (void)enumerateAttribute: (NSAttributedStringKey) attrName
inRange: (NSRange) enumerationRange
options: (NSAttributedStringEnumerationOptions) opts
usingBlock: (void (^)(id value, NSRange range, BOOL *stop)) block;
#pragma mark - #pragma mark -
#pragma mark Testing String Data Sources #pragma mark Testing String Data Sources

View File

@ -23,18 +23,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
@class NSWindow, NSWindowController, NSSavePanel, NSMenuItem, NSFileWrapper, @class NSWindow, NSWindowController, NSSavePanel, NSMenuItem, NSFileWrapper,
NSPrintOperation, NSPrintInfo, NSPageLayout, NSView; NSPrintOperation, NSPrintInfo, NSPageLayout, NSView;
typedef enum { typedef enum NSDocumentChangeType : NSUInteger {
NSChangeDone, NSChangeDone,
NSChangeUndone, NSChangeUndone,
NSChangeCleared, NSChangeCleared,
NSChangeReadOtherContents, NSChangeReadOtherContents,
NSChangeAutosaved, NSChangeAutosaved,
NSChangeRedone,
NSChangeDiscardable = 256,
} NSDocumentChangeType; } NSDocumentChangeType;
typedef enum { typedef enum {
NSSaveOperation, NSSaveOperation,
NSSaveAsOperation, NSSaveAsOperation,
NSSaveToOperation, NSSaveToOperation,
NSAutosaveElsewhereOperation,
NSAutosaveInPlaceOperation,
NSAutosaveAsOperation,
NSAutosaveOperation, NSAutosaveOperation,
} NSSaveOperationType; } NSSaveOperationType;
@ -230,7 +235,7 @@ typedef enum {
(NSSaveOperationType) operation; (NSSaveOperationType) operation;
- (NSFileWrapper *) fileWrapperRepresentationOfType: (NSString *) type; - (NSFileWrapper *) fileWrapperRepresentationOfType: (NSString *) type;
- initWithContentsOfFile: (NSString *) path ofType: (NSString *) type; - initWithContentsOfFile: (NSString *) path ofType: (NSString *) type;
- initWithContentsOfURL: (NSURL *) url ofType: (NSString *) type; - (id) initWithContentsOfURL: (NSURL *) url ofType: (NSString *) type;
- (BOOL) loadDataRepresentation: (NSData *) data ofType: (NSString *) type; - (BOOL) loadDataRepresentation: (NSData *) data ofType: (NSString *) type;
- (BOOL) loadFileWrapperRepresentation: (NSFileWrapper *) wrapper - (BOOL) loadFileWrapperRepresentation: (NSFileWrapper *) wrapper
ofType: (NSString *) type; ofType: (NSString *) type;
@ -259,4 +264,12 @@ typedef enum {
ofType: (NSString *) type ofType: (NSString *) type
saveOperation: (NSSaveOperationType) operation; saveOperation: (NSSaveOperationType) operation;
- (void)saveToURL: (NSURL *) url
ofType: (NSString *) typeName
forSaveOperation: (NSSaveOperationType) saveOperation
completionHandler: (void (^)(NSError *errorOrNil)) completionHandler;
- (void)autosaveWithImplicitCancellability: (BOOL) autosavingIsImplicitlyCancellable
completionHandler: (void (^)(NSError *errorOrNil)) completionHandler;
@end @end

View File

@ -32,6 +32,11 @@ typedef enum {
NSGlyphInscribeOverBelow, NSGlyphInscribeOverBelow,
} NSGlyphInscription; } NSGlyphInscription;
typedef NS_ENUM(NSInteger, NSTextLayoutOrientation) {
NSTextLayoutOrientationHorizontal,
NSTextLayoutOrientationVertical,
};
@interface NSLayoutManager : NSObject { @interface NSLayoutManager : NSObject {
NSTextStorage *_textStorage; NSTextStorage *_textStorage;
NSGlyphGenerator *_glyphGenerator; NSGlyphGenerator *_glyphGenerator;
@ -47,6 +52,7 @@ typedef enum {
struct NSRangeEntries *_rangeToTemporaryAttributes; struct NSRangeEntries *_rangeToTemporaryAttributes;
BOOL _layoutInvalid; BOOL _layoutInvalid;
BOOL _allowsNonContiguousLayout;
NSRect _extraLineFragmentRect; NSRect _extraLineFragmentRect;
NSRect _extraLineFragmentUsedRect; NSRect _extraLineFragmentUsedRect;
@ -126,6 +132,8 @@ typedef enum {
- (NSRect) extraLineFragmentUsedRect; - (NSRect) extraLineFragmentUsedRect;
- (NSTextContainer *) extraLineFragmentTextContainer; - (NSTextContainer *) extraLineFragmentTextContainer;
- (BOOL) allowsNonContiguousLayout;
- (void) setTextContainer: (NSTextContainer *) container - (void) setTextContainer: (NSTextContainer *) container
forGlyphRange: (NSRange) glyphRange; forGlyphRange: (NSRange) glyphRange;
- (void) setLineFragmentRect: (NSRect) fragmentRect - (void) setLineFragmentRect: (NSRect) fragmentRect
@ -268,6 +276,8 @@ typedef enum {
paragraphStyle: (NSParagraphStyle *) style paragraphStyle: (NSParagraphStyle *) style
ruler: (NSRulerView *) ruler ruler: (NSRulerView *) ruler
enabled: (BOOL) isEnabled; enabled: (BOOL) isEnabled;
- (void) setAllowsNonContiguousLayout: (BOOL) value;
@end @end
@protocol NSLayoutManagerDelegate <NSObject> @protocol NSLayoutManagerDelegate <NSObject>
@ -284,4 +294,6 @@ typedef enum {
@protocol NSTextLayoutOrientationProvider @protocol NSTextLayoutOrientationProvider
- (NSTextLayoutOrientation) layoutOrientation;
@end @end

View File

@ -25,4 +25,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
- (void) fixParagraphStyleAttributeInRange: (NSRange) range; - (void) fixParagraphStyleAttributeInRange: (NSRange) range;
- (void) fixAttributesInRange: (NSRange) range; - (void) fixAttributesInRange: (NSRange) range;
- (void) applyFontTraits: (NSFontTraitMask) traits range: (NSRange) range; - (void) applyFontTraits: (NSFontTraitMask) traits range: (NSRange) range;
- (BOOL) readFromURL: (NSURL *) url
options: (NSDictionary<NSAttributedStringDocumentReadingOptionKey, id> *) opts
documentAttributes: (NSDictionary<NSAttributedStringDocumentAttributeKey, id> * _Nullable *) dict
error: (NSError * _Nullable *)error;
- (void)addAttribute: (NSAttributedStringKey) name
value: (id) value
range: (NSRange) range;
@end @end

View File

@ -18,6 +18,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSParagraphStyle.h> #import <AppKit/NSParagraphStyle.h>
#import <AppKit/NSTextTab.h>
@interface NSMutableParagraphStyle : NSParagraphStyle @interface NSMutableParagraphStyle : NSParagraphStyle
@ -47,6 +48,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
- (void) setDefaultTabInterval: (CGFloat) interval; - (void) setDefaultTabInterval: (CGFloat) interval;
- (void) setTabStops: (NSArray *) tabStops; - (void) setTabStops: (NSArray *) tabStops;
- (void) addTabStop: (NSTextTab *) tabStop;
- (void) removeTabStop: (NSTextTab *) tabStop;
- (void) setHyphenationFactor: (float) factor; - (void) setHyphenationFactor: (float) factor;
- (void) setTighteningFactorForTruncation: (float) factor; - (void) setTighteningFactorForTruncation: (float) factor;

View File

@ -45,13 +45,15 @@ typedef enum {
CGFloat _lineHeightMultiple; CGFloat _lineHeightMultiple;
CGFloat _lineSpacing; CGFloat _lineSpacing;
CGFloat _defaultTabInterval; CGFloat _defaultTabInterval;
NSArray *_tabStops; NSMutableArray *_tabStops;
float _hyphenationFactor; float _hyphenationFactor;
float _tighteningFactorForTruncation; float _tighteningFactorForTruncation;
} }
+ (NSParagraphStyle *) defaultParagraphStyle; + (NSParagraphStyle *) defaultParagraphStyle;
+ (NSWritingDirection)defaultWritingDirectionForLanguage: (NSString *)languageName;
- (NSWritingDirection) baseWritingDirection; - (NSWritingDirection) baseWritingDirection;
- (CGFloat) paragraphSpacing; - (CGFloat) paragraphSpacing;

View File

@ -19,6 +19,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/AppKitExport.h> #import <AppKit/AppKitExport.h>
#import <AppKit/NSView.h> #import <AppKit/NSView.h>
#import <AppKit/NSControl.h>
#import <AppKit/NSScroller.h>
#import <Foundation/NSString.h> #import <Foundation/NSString.h>
@class NSClipView, NSScroller, NSColor, NSRulerView; @class NSClipView, NSScroller, NSColor, NSRulerView;
@ -50,16 +52,32 @@ APPKIT_EXPORT NSString *const NSScrollViewDidLiveScrollNotification;
BOOL _scrollsDynamically; BOOL _scrollsDynamically;
BOOL _autohidesScrollers; BOOL _autohidesScrollers;
NSCursor *_documentCursor; NSCursor *_documentCursor;
BOOL _allowsMagnification;
CGFloat _magnification;
CGFloat _minMagnification;
CGFloat _maxMagnification;
} }
+ (NSSize) frameSizeForContentSize: (NSSize) contentSize + (NSSize) frameSizeForContentSize: (NSSize) contentSize
hasHorizontalScroller: (BOOL) hasHorizontalScroller hasHorizontalScroller: (BOOL) hasHorizontalScroller
hasVerticalScroller: (BOOL) hasVerticalScroller hasVerticalScroller: (BOOL) hasVerticalScroller
borderType: (NSBorderType) borderType; borderType: (NSBorderType) borderType;
+ (NSSize)frameSizeForContentSize: (NSSize)cSize
horizontalScrollerClass: (Class)horizontalScrollerClass
verticalScrollerClass: (Class)verticalScrollerClass
borderType: (NSBorderType)type
controlSize: (NSControlSize)controlSize
scrollerStyle: (NSScrollerStyle)scrollerStyle;
+ (NSSize) contentSizeForFrameSize: (NSSize) fSize + (NSSize) contentSizeForFrameSize: (NSSize) fSize
hasHorizontalScroller: (BOOL) hasHorizontalScroller hasHorizontalScroller: (BOOL) hasHorizontalScroller
hasVerticalScroller: (BOOL) hasVerticalScroller hasVerticalScroller: (BOOL) hasVerticalScroller
borderType: (NSBorderType) borderType; borderType: (NSBorderType) borderType;
+ (NSSize)contentSizeForFrameSize: (NSSize)fSize
horizontalScrollerClass: (Class)horizontalScrollerClass
verticalScrollerClass: (Class)verticalScrollerClass
borderType: (NSBorderType)type
controlSize: (NSControlSize)controlSize
scrollerStyle: (NSScrollerStyle)scrollerStyle;
+ (void) setRulerViewClass: (Class) aClass; + (void) setRulerViewClass: (Class) aClass;
+ (Class) rulerViewClass; + (Class) rulerViewClass;
@ -94,6 +112,10 @@ APPKIT_EXPORT NSString *const NSScrollViewDidLiveScrollNotification;
- (BOOL) autohidesScrollers; - (BOOL) autohidesScrollers;
- (NSCursor *) documentCursor; - (NSCursor *) documentCursor;
- (CGFloat) magnification;
- (CGFloat) minMagnification;
- (CGFloat) maxMagnification;
- (BOOL) allowsMagnification;
- (void) setDocumentView: (NSView *) view; - (void) setDocumentView: (NSView *) view;
- (void) setContentView: (NSClipView *) clipView; - (void) setContentView: (NSClipView *) clipView;
@ -116,6 +138,10 @@ APPKIT_EXPORT NSString *const NSScrollViewDidLiveScrollNotification;
- (void) setScrollsDynamically: (BOOL) flag; - (void) setScrollsDynamically: (BOOL) flag;
- (void) setDocumentCursor: (NSCursor *) cursor; - (void) setDocumentCursor: (NSCursor *) cursor;
- (void) setAutohidesScrollers: (BOOL) value; - (void) setAutohidesScrollers: (BOOL) value;
- (void) setMagnification: (CGFloat) value;
- (void) setMinMagnification: (CGFloat) value;
- (void) setMaxMagnification: (CGFloat) value;
- (void) setAllowsMagnification: (BOOL) value;
- (void) tile; - (void) tile;
- (void) reflectScrolledClipView: (NSClipView *) clipView; - (void) reflectScrolledClipView: (NSClipView *) clipView;

View File

@ -46,6 +46,12 @@ enum {
NSOnlyScrollerArrows = 1, NSOnlyScrollerArrows = 1,
NSAllScrollerParts = 2, NSAllScrollerParts = 2,
}; };
typedef NS_ENUM(NSInteger, NSScrollerStyle) {
NSScrollerStyleLegacy,
NSScrollerStyleOverlay,
};
typedef NSUInteger NSUsableScrollerParts; typedef NSUInteger NSUsableScrollerParts;
@interface NSScroller : NSControl { @interface NSScroller : NSControl {
@ -64,6 +70,8 @@ typedef NSUInteger NSUsableScrollerParts;
NSScrollerPart _hitPart; NSScrollerPart _hitPart;
BOOL _isEnabled; BOOL _isEnabled;
BOOL _isHighlighted; BOOL _isHighlighted;
NSScrollerStyle _scrollerStyle;
} }
+ (CGFloat) scrollerWidth; + (CGFloat) scrollerWidth;
@ -71,11 +79,14 @@ typedef NSUInteger NSUsableScrollerParts;
- (CGFloat) knobProportion; - (CGFloat) knobProportion;
- (NSScrollArrowPosition) arrowsPosition; - (NSScrollArrowPosition) arrowsPosition;
- (NSControlSize) controlSize; - (NSControlSize) controlSize;
- (NSScrollerStyle) scrollerStyle;
+ (NSScrollerStyle) preferredScrollerStyle;
- (void) setFloatValue: (float) zeroToOneValue - (void) setFloatValue: (float) zeroToOneValue
knobProportion: (CGFloat) zeroToOneKnob; knobProportion: (CGFloat) zeroToOneKnob;
- (void) setArrowsPosition: (NSScrollArrowPosition) position; - (void) setArrowsPosition: (NSScrollArrowPosition) position;
- (void) setControlSize: (NSControlSize) value; - (void) setControlSize: (NSControlSize) value;
- (void) setScrollerStyle: (NSScrollerStyle) style;
- (NSRect) rectForPart: (NSScrollerPart) part; - (NSRect) rectForPart: (NSScrollerPart) part;
- (void) checkSpaceForParts; - (void) checkSpaceForParts;

View File

@ -49,4 +49,5 @@ APPKIT_EXPORT NSString *NSTabColumnTerminatorsAttributeName;
- (CGFloat) location; - (CGFloat) location;
- (NSComparisonResult) compare: (id) anObject;
@end @end

View File

@ -30,6 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSText.h> #import <AppKit/NSText.h>
#import <AppKit/NSTextInput.h> #import <AppKit/NSTextInput.h>
#import <AppKit/NSTextInputClient.h> #import <AppKit/NSTextInputClient.h>
#import <AppKit/NSLayoutManager.h>
#import <Foundation/NSTextCheckingResult.h> #import <Foundation/NSTextCheckingResult.h>
@ -68,7 +69,7 @@ APPKIT_EXPORT NSString *const NSAllRomanInputSourcesLocaleIdentifier;
@class NSUndoTyping; @class NSUndoTyping;
@interface NSTextView : NSText <NSTextInput> { @interface NSTextView : NSText <NSTextInput, NSTextLayoutOrientationProvider> {
NSTextStorage *_textStorage; NSTextStorage *_textStorage;
NSTextContainer *_textContainer; NSTextContainer *_textContainer;
NSSize _textContainerInset; NSSize _textContainerInset;
@ -98,6 +99,7 @@ APPKIT_EXPORT NSString *const NSAllRomanInputSourcesLocaleIdentifier;
BOOL _usesRuler; BOOL _usesRuler;
BOOL _rulerVisible; BOOL _rulerVisible;
BOOL _usesFontPanel; BOOL _usesFontPanel;
BOOL _usesFindBar;
BOOL _allowsUndo; BOOL _allowsUndo;
NSMutableArray *_selectedRanges; NSMutableArray *_selectedRanges;
@ -129,14 +131,30 @@ APPKIT_EXPORT NSString *const NSAllRomanInputSourcesLocaleIdentifier;
BOOL _isContinuousSpellCheckingEnabled; BOOL _isContinuousSpellCheckingEnabled;
BOOL _isAutomaticSpellingCorrectionEnabled; BOOL _isAutomaticSpellingCorrectionEnabled;
NSTextCheckingTypes _enabledTextCheckingTypes; NSTextCheckingTypes _enabledTextCheckingTypes;
BOOL _smartInsertDeleteEnabled;
BOOL _allowsDocumentBackgroundColorChange;
NSUndoTyping *_undoTyping; NSUndoTyping *_undoTyping;
NSTextLayoutOrientation _layoutOrientation;
BOOL _incrementalSearchingEnabled;
BOOL _grammarCheckingEnabled;
BOOL _automaticQuoteSubstitutionEnabled;
BOOL _automaticDashSubstitutionEnabled;
BOOL _automaticLinkDetectionEnabled;
BOOL _automaticDataDetectionEnabled;
BOOL _automaticTextReplacementEnabled;
BOOL _usesInspectorBar;
} }
- initWithFrame: (NSRect) frame textContainer: (NSTextContainer *) container; - initWithFrame: (NSRect) frame textContainer: (NSTextContainer *) container;
- initWithFrame: (NSRect) frame; - initWithFrame: (NSRect) frame;
- (void) _setTextStorage: (NSTextStorage *) storage;
- (NSTextContainer *) textContainer; - (NSTextContainer *) textContainer;
- (NSSize) textContainerInset; - (NSSize) textContainerInset;
@ -250,8 +268,36 @@ APPKIT_EXPORT NSString *const NSAllRomanInputSourcesLocaleIdentifier;
- (NSTextCheckingTypes) enabledTextCheckingTypes; - (NSTextCheckingTypes) enabledTextCheckingTypes;
- (void) setEnabledTextCheckingTypes: (NSTextCheckingTypes) checkingTypes; - (void) setEnabledTextCheckingTypes: (NSTextCheckingTypes) checkingTypes;
- (BOOL) smartInsertDeleteEnabled;
- (void) setSmartInsertDeleteEnabled: (BOOL) boolForKey;
- (BOOL) allowsDocumentBackgroundColorChange;
- (void) setAllowsDocumentBackgroundColorChange: (BOOL) value;
- (void) setSpellingState: (NSInteger) value range: (NSRange) characterRange; - (void) setSpellingState: (NSInteger) value range: (NSRange) characterRange;
- (BOOL) isIncrementalSearchingEnabled;
- (BOOL) usesFindBar;
- (BOOL) usesInspectorBar;
- (void) setIncrementalSearchingEnabled: (BOOL) value;
- (void) setUsesFindBar: (BOOL) value;
- (void) setUsesInspectorBar: (BOOL) value;
- (void) setLayoutOrientation:(NSTextLayoutOrientation)orientation;
- (BOOL) isGrammarCheckingEnabled;
- (BOOL) isAutomaticQuoteSubstitutionEnabled;
- (BOOL) isAutomaticDashSubstitutionEnabled;
- (BOOL) isAutomaticLinkDetectionEnabled;
- (BOOL) isAutomaticDataDetectionEnabled;
- (BOOL) isAutomaticTextReplacementEnabled;
- (void) setGrammarCheckingEnabled: (BOOL) value;
- (void) setAutomaticQuoteSubstitutionEnabled: (BOOL) value;
- (void) setAutomaticDashSubstitutionEnabled: (BOOL) value;
- (void) setAutomaticLinkDetectionEnabled: (BOOL) value;
- (void) setAutomaticDataDetectionEnabled: (BOOL) value;
- (void) setAutomaticTextReplacementEnabled: (BOOL) value;
@end @end
@interface NSObject (NSTextView_undoManager) @interface NSObject (NSTextView_undoManager)

View File

@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#import <AppKit/NSAnimation.h> #import <AppKit/NSAnimation.h>
#import <AppKit/NSGraphics.h> #import <AppKit/NSGraphics.h>
#import <AppKit/NSResponder.h> #import <AppKit/NSResponder.h>
#import <AppKit/NSUserInterfaceItemIdentification.h>
#import <ApplicationServices/ApplicationServices.h> #import <ApplicationServices/ApplicationServices.h>
#import <AppKit/NSUserInterfaceItemIdentification.h> #import <AppKit/NSUserInterfaceItemIdentification.h>
#import <AppKit/NSLayoutConstraint.h> #import <AppKit/NSLayoutConstraint.h>
@ -109,6 +110,7 @@ APPKIT_EXPORT const NSViewFullScreenModeOptionKey NSFullScreenModeApplicationPre
NSInteger _rectsBeingRedrawnCount; NSInteger _rectsBeingRedrawnCount;
CGFloat _frameRotation; CGFloat _frameRotation;
CGFloat _boundsRotation; CGFloat _boundsRotation;
BOOL _translatesAutoresizingMaskIntoConstraints;
BOOL _validTrackingAreas; BOOL _validTrackingAreas;
BOOL _validTransforms; BOOL _validTransforms;
@ -134,7 +136,6 @@ APPKIT_EXPORT const NSViewFullScreenModeOptionKey NSFullScreenModeApplicationPre
NSLayoutPriority _verticalContentHuggingPriority; NSLayoutPriority _verticalContentHuggingPriority;
NSLayoutPriority _horizontalContentCompressionResistancePriority; NSLayoutPriority _horizontalContentCompressionResistancePriority;
NSLayoutPriority _verticalContentCompressionResistancePriority; NSLayoutPriority _verticalContentCompressionResistancePriority;
BOOL _translatesAutoresizingMaskIntoConstraints;
} }
@property(class, readonly) BOOL requiresConstraintBasedLayout; @property(class, readonly) BOOL requiresConstraintBasedLayout;