-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for standard ODB editor suite, as originally specified by Bar…
…eBones <http://www.barebones.com/support/develop/odbsuite.html>; this implementation based on code from <http://gusmueller.com/odb/>
- Loading branch information
Showing
6 changed files
with
491 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This work is hereby released into the Public Domain. To view a copy of the public domain dedication, visit http://creativecommons.org/licenses/publicdomain/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSAppleEventDescriptor(Extensions) | ||
|
||
+ (NSAppleEventDescriptor *)descriptorWithFilePath:(NSString *)fileName; | ||
+ (NSAppleEventDescriptor *)descriptorWithFileURL:(NSURL *)fileURL; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#import "NSAppleEventDescriptor-Extensions.h" | ||
|
||
@implementation NSAppleEventDescriptor(Extensions) | ||
|
||
+ (NSAppleEventDescriptor *)descriptorWithFilePath:(NSString *)fileName { | ||
NSURL *url = [NSURL fileURLWithPath: fileName]; | ||
return [self descriptorWithFileURL: url]; | ||
} | ||
|
||
+ (NSAppleEventDescriptor *)descriptorWithFileURL:(NSURL *)fileURL { | ||
NSString *string = [fileURL absoluteString]; | ||
NSData *data = [string dataUsingEncoding: NSUTF8StringEncoding]; | ||
return [self descriptorWithDescriptorType: typeFileURL data: data]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#import <Cocoa/Cocoa.h> | ||
|
||
// http://gusmueller.com/odb/ | ||
|
||
extern NSString * const ODBEditorCustomPathKey; | ||
|
||
@class TemporaryFileCachePreparer; | ||
|
||
@interface ODBEditor : NSObject | ||
{ | ||
UInt32 _signature; | ||
NSMutableDictionary *_filePathsBeingEdited; | ||
|
||
int currentNoteStorageFormat; | ||
TemporaryFileCachePreparer *editingSpacePreparer; | ||
} | ||
+ (id)sharedODBEditor; | ||
|
||
- (void)abortEditingFile:(NSString *)path; | ||
- (void)abortAllEditingSessionsForClient:(id)client; | ||
|
||
- (void)initializeDatabaseFormat:(int)fmt; | ||
- (BOOL)fileCacheIsValid; | ||
|
||
// NOTE that client is never retained - it is your reponsibility to | ||
// make sure the client sticks around and abort editing for that client | ||
// before it is dealloc'd | ||
// | ||
// Also note that while it is possible to start several editString | ||
// sessions for a single client it is the client's responsibility to | ||
// distinguish between the sessions (possibly using the original | ||
// context that you supplied.) It is also the clients responsibility to | ||
// do the same for file editing sessions, but this should be easier | ||
// since the file path will remain static (except in the save as case) | ||
// whereas the string returned is obviously going to change as the user | ||
// edits it. | ||
|
||
- (BOOL)editFile:(NSString *)path options:(NSDictionary *)options forClient:(id)client context:(NSDictionary *)context; | ||
|
||
- (BOOL)editString:(NSString *)string options:(NSDictionary *)options forClient:(id)client context:(NSDictionary *)context; | ||
|
||
@end | ||
|
||
@interface NSObject(ODBEditorClient) | ||
|
||
// see the ODB Editor documentation for when newFileLocation is sent | ||
// if the file wasn't subject to a save as newpath will be nil | ||
|
||
-(void)odbEditor:(ODBEditor *)editor didModifyFile:(NSString *)path newFileLocation:(NSString *)newPath context:(NSDictionary *)context; | ||
-(void)odbEditor:(ODBEditor *)editor didClosefile:(NSString *)path context:(NSDictionary *)context; | ||
|
||
-(void)odbEditor:(ODBEditor *)editor didModifyFileForString:(NSString *)newString context:(NSDictionary *)context; | ||
-(void)odbEditor:(ODBEditor *)editor didCloseFileForString:(NSString *)newString context:(NSDictionary *)context; | ||
|
||
@end |
Oops, something went wrong.