Cannot remember what changes I made

This commit is contained in:
Nicholas Shanks 2002-05-31 00:17:53 +00:00
parent 7b6cbbc706
commit f99332cc12
16 changed files with 458 additions and 38 deletions

View File

@ -39,6 +39,7 @@ int main( int argc, char* argv[] )
QuitResKnife();
}
#if TARGET_API_MAC_CARBON
// check carbon version is at least 1.1
error = Gestalt( gestaltCarbonVersion, &g.carbonVersion );
if( g.carbonVersion < kCarbonLib11 || error )
@ -50,6 +51,7 @@ int main( int argc, char* argv[] )
{
DisplayError( kStringRecommendedCarbonLib, kExplanationRecommendedCarbonLib );
}
#endif
#if __profile__
error = ProfilerInit( collectDetailed, bestTimeBase, 400, 40 );

View File

@ -159,7 +159,7 @@ resource 'xmnu' (200, purgeable)
#define kAEResourceType 'type'
#define kAECompactResource 'cpct'
resource kAETerminologyExtension ( roman, "AppleScript Dictionary" )
resource kAETerminologyExtension ( 0, "AppleScript Dictionary" )
{
1, // major version
0, // minor version
@ -344,7 +344,7 @@ resource kAETerminologyExtension ( roman, "AppleScript Dictionary" )
/* b */ "type",
kAEResourceType,
typeSInt16,
typeUInt32,
"the type of the resource (four chars in length)",
reserved,
singleItem,

View File

@ -1,22 +1,61 @@
#import <Cocoa/Cocoa.h>
/*! @header ApplicationDelegate.h
* @discussion This class is the delegate object for NSApp.
*/
/*! @class ApplicationDelegate
* @discussion This class is the delegate object for NSApp.
*/
@interface ApplicationDelegate : NSObject
{
/*! @var icons A dictionary within which to cache icons. Keys are four-character <tt>NSStrings</tt> representing <tt>ResTypes</tt>. */
NSMutableDictionary *icons;
}
/*! @function showAbout:
* @discussion Displays the about box located in <b>AboutPanel.nib</b>.
*/
- (IBAction)showAbout:(id)sender;
/*! @function visitWebsite:
* @discussion Takes the user to <i>http://web.nickshanks.com/resknife/</i>.
*/
- (IBAction)visitWebsite:(id)sender;
/*! @function visitSourceforge:
* @discussion Takes the user to <i>http://resknife.sourceforge.net/</i>.
*/
- (IBAction)visitSourceforge:(id)sender;
/*! @function emailDeveloper:
* @discussion Launches email client and inserts <i>resknife@nickshanks.com</i> into To field.
*/
- (IBAction)emailDeveloper:(id)sender;
/*! @function showInfo:
* @discussion Displays the Info panel stored in <b>InfoWindow.nib</b>
*/
- (IBAction)showInfo:(id)sender;
/*! @function showPrefs:
* @discussion Displays the preferences panel stored in <b>PrefsWindow.nib</b>
*/
- (IBAction)showPrefs:(id)sender;
/*! @function initUserDefaults
* @discussion Initalises any unset user preferences to default values as read in from <b>defaults.plist</b>.
*/
- (void)initUserDefaults;
/*! @function icons
* @discussion Accessor method for the <tt>icons</tt> instance variable.
*/
- (NSDictionary *)icons;
@end
@interface NSSavePanel (PackageBrowser)
@end

View File

@ -24,6 +24,7 @@
// save a number of icons
icons = [[NSMutableDictionary alloc] init];
[icons setObject:[[NSWorkspace sharedWorkspace] iconForFileType:@"TEXT"] forKey:@"TEXT"];
[icons setObject:[[NSWorkspace sharedWorkspace] iconForFileType:@"PICT"] forKey:@"PICT"];
[icons setObject:[[NSWorkspace sharedWorkspace] iconForFileType:@"icns"] forKey:@"icns"];
@ -50,6 +51,13 @@
else return NO; // should be @"None", but we shall return NO for any other value
}
- (BOOL)application:(NSApplication *)application openFile:(NSString *)file
{
#pragma unused( application )
// bug: check if application was an external editor (e.g. Iconographer) and update existing open file instead
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfFile:file display:YES];
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
{
#pragma unused( sender )
@ -64,7 +72,7 @@
- (IBAction)visitWebsite:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://nickshanks.com/resknife/"]];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://web.nickshanks.com/resknife/"]];
}
- (IBAction)visitSourceforge:(id)sender

View File

@ -13,7 +13,7 @@
if( [type length] == 4 && [[resIDView stringValue] length] > 0 )
{
// I could use +[Resource resourceOfType:andID:inDocument:] != nil, but that would be much slower
// I could use +[Resource getResourceOfType:andID:inDocument:] != nil, but that would be much slower
Resource *resource;
NSEnumerator *enumerator = [[[document dataSource] resources] objectEnumerator];
while( resource = [enumerator nextObject] )

View File

@ -31,8 +31,16 @@
[(ResourceNameCell *)cell setImage:[[(ApplicationDelegate *)[NSApp delegate] icons] valueForKey:[(Resource *)item type]]];
}
if( row % 2 == 0 ) [cell setBackgroundColor:[NSColor whiteColor]];
else [cell setBackgroundColor:[NSColor colorWithCalibratedRed:0.93 green:0.95 blue:1.0 alpha:1.0]];
if( row % 2 )
{
[cell setDrawsBackground:NO];
[cell setBackgroundColor:[NSColor whiteColor]];
}
else
{
[cell setDrawsBackground:YES];
[cell setBackgroundColor:[NSColor colorWithCalibratedRed:0.93 green:0.95 blue:1.0 alpha:1.0]];
}
}
@end

View File

@ -54,7 +54,7 @@
return [resource autorelease];
}
+ (NSArray *)allResourcesOfType:(NSString *)typeValue inDocument:(NSDocument *)document
+ (NSArray *)getAllResourcesOfType:(NSString *)typeValue inDocument:(NSDocument *)document
{
NSMutableArray *array = [NSMutableArray array];
NSDocument *doc;
@ -68,7 +68,7 @@
return [NSArray arrayWithArray:array];
}
+ (Resource *)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue inDocument:(NSDocument *)document
+ (Resource *)getResourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue inDocument:(NSDocument *)document
{
NSDocument *doc;
NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator];

View File

@ -57,6 +57,9 @@ NSString *DocumentInfoDidChangeNotification = @"DocumentInfoDidChangeNotificat
[[outlineView tableColumnWithIdentifier:@"name"] setDataCell:resourceNameCell];
}
// set outline view's inter-cell psacing to zero to avoid getting gaps between blue bits
[outlineView setIntercellSpacing:NSMakeSize(0,0)];
// register for resource will change notifications (for undo management)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resourceNameWillChange:) name:ResourceNameWillChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resourceIDWillChange:) name:ResourceIDWillChangeNotification object:nil];

View File

@ -5,10 +5,9 @@
@interface HexTextView : NSTextView
{
}
- (void)editData:(NSMutableData *)data replaceBytesInRange:(NSRange)range withData:(NSData *)newData;
@end
@interface NSTextView (HexTextView)
- (void)swapForHexTextView;
@end

View File

@ -128,10 +128,10 @@
}
}
}
// replace bytes (updates views implicitly)
[data replaceBytesInRange:byteSelection withBytes:[replaceData bytes] length:[replaceData length]];
[[(HexWindowController *)[[self window] windowController] resource] setData:data];
// replace bytes (updates views implicitly, records an undo)
[self editData:data replaceBytesInRange:byteSelection withData:replaceData];
[data release];
// set the new selection/insertion point
byteSelection.location++;
@ -141,8 +141,6 @@
else if( self == (id) [[self delegate] ascii] )
selection = [[self delegate] asciiRangeFromByteRange:byteSelection];
[self setSelectedRange:selection];
[data release];
NSLog(@"undo manager %@", [[self window] undoManager]);
}
- (IBAction)deleteBackward:(id)sender
@ -169,8 +167,7 @@
}
// replace bytes (updates views implicitly)
[data replaceBytesInRange:byteSelection withBytes:nil length:0];
[[(HexWindowController *)[[self window] windowController] resource] setData:data];
[self editData:data replaceBytesInRange:byteSelection withData:[NSData data]];
[data release];
// set the new selection/insertion point
@ -201,8 +198,7 @@
byteSelection.length = 1;
// replace bytes (updates views implicitly)
[data replaceBytesInRange:byteSelection withBytes:nil length:0];
[[(HexWindowController *)[[self window] windowController] resource] setData:data];
[self editData:data replaceBytesInRange:byteSelection withData:[NSData data]];
[data release];
// set the new selection/insertion point
@ -230,6 +226,24 @@
[self transpose:sender];
}
- (void)editData:(NSMutableData *)data replaceBytesInRange:(NSRange)range withData:(NSData *)newData
{
// record an undo
NSRange newRange = NSMakeRange( range.location, [newData length] );
NSData *oldData = [[data subdataWithRange:range] retain]; // bug: memory leak, need to release somewhere
[[[[self window] undoManager] prepareWithInvocationTarget:self] editData:data replaceBytesInRange:newRange withData:oldData];
[[[self window] undoManager] setActionName:NSLocalizedString(@"Typing", nil)];
NSLog( @"Edit Called: replaceBytesInRange: %@ withData: %@", NSStringFromRange(range), [[[NSString alloc] initWithData:newData encoding:NSMacOSRomanStringEncoding] autorelease] );
NSLog( @"Edit Saved: replaceBytesInRange: %@ withData: %@", NSStringFromRange(newRange), [[[NSString alloc] initWithData:oldData encoding:NSMacOSRomanStringEncoding] autorelease] );
// replace bytes (updates views implicitly)
[data replaceBytesInRange:range withBytes:[newData bytes] length:[newData length]];
[[(HexWindowController *)[[self window] windowController] resource] setData:data];
[self setSelectedRange:NSMakeRange(range.location, [newData length])];
[[self window] setDocumentEdited:YES];
}
@end
@implementation NSTextView (HexTextView)

View File

@ -13,7 +13,7 @@
IBOutlet NSTextView *offset;
IBOutlet NSTextField *message;
NSUndoManager *hexUndo;
NSUndoManager *undoManager;
id <ResKnifeResourceProtocol> resource;
int bytesPerRow;
}

View File

@ -10,9 +10,9 @@
if( !self ) return self;
// one instance of your principal class will be created for every resource the user wants to edit (similar to Windows apps)
undoManager = [[NSUndoManager alloc] init];
resource = [newResource retain];
bytesPerRow = 16;
hexUndo = [[NSUndoManager alloc] init];
// load the window from the nib file and set it's title
[self window]; // implicitly loads nib
@ -23,6 +23,7 @@
- (id)initWithResources:(id)newResource, ...
{
[undoManager release];
return nil;
}
@ -65,6 +66,11 @@
// finally, show the window
[self showWindow:self];
}
/*
- (BOOL)windowShouldClose:(NSWindow *)sender
{
return [sender isDocumentEdited];
}*/
- (IBAction)showFind:(id)sender
{
@ -181,8 +187,7 @@
- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)sender
{
NSLog(@"returning undo manager %@", hexUndo);
return hexUndo;
return undoManager;
}
@end

View File

@ -2,5 +2,5 @@
int main(int argc, const char *argv[])
{
return NSApplicationMain(argc, argv);
return NSApplicationMain(argc, argv);
}

View File

@ -6,10 +6,6 @@
<string>120 159 356 240 0 0 1152 848 </string>
<key>IBFramework Version</key>
<string>263.2</string>
<key>IBOpenObjects</key>
<array>
<integer>5</integer>
</array>
<key>IBSystem Version</key>
<string>5Q125</string>
</dict>

Binary file not shown.

View File

@ -291,6 +291,347 @@
settings = {
};
};
F54625C6029174F601A8010C = {
isa = PBXFrameworkReference;
name = CoreServices.framework;
path = /System/Library/Frameworks/CoreServices.framework;
refType = 0;
};
F54626490291750201A8010C = {
isa = PBXFrameworkReference;
name = ApplicationServices.framework;
path = /System/Library/Frameworks/ApplicationServices.framework;
refType = 0;
};
F54627040291767E01A8010C = {
isa = PBXFileReference;
path = "ResKnife-rsrcfork.rsrc";
refType = 4;
};
F54627050291767E01A8010C = {
fileRef = F54627040291767E01A8010C;
isa = PBXBuildFile;
settings = {
};
};
F54627060291788401A8010C = {
isa = PBXTargetDependency;
target = F5B588D20156D78201000001;
};
F54627070291788801A8010C = {
isa = PBXTargetDependency;
target = F5B588EE0156DAF301000001;
};
F54627080291788A01A8010C = {
isa = PBXTargetDependency;
target = F5B5890B0156DC2201000001;
};
F546270B02917D1501A8010C = {
buildActionMask = 2147483647;
files = (
F546271302917DC501A8010C,
F546271402917DC601A8010C,
F546271502917DC701A8010C,
F546271602917DC801A8010C,
F546271802917DCB01A8010C,
F546271A02917DCD01A8010C,
F546271C02917DCE01A8010C,
F546271E02917DD101A8010C,
F546272002917DD201A8010C,
F546272202917DD301A8010C,
F546272402917DD601A8010C,
F546272602917DD701A8010C,
F546272802917DE001A8010C,
F546272A02917DE201A8010C,
F546272C02917DE401A8010C,
F546272E02917DE601A8010C,
F546273002917DE701A8010C,
F546273202917DE801A8010C,
);
isa = PBXHeadersBuildPhase;
};
F546270C02917D1501A8010C = {
buildActionMask = 2147483647;
files = (
F546271702917DC901A8010C,
F546271902917DCC01A8010C,
F546271B02917DCD01A8010C,
F546271D02917DCF01A8010C,
F546271F02917DD101A8010C,
F546272102917DD301A8010C,
F546272302917DD501A8010C,
F546272502917DD601A8010C,
F546272702917DE001A8010C,
F546272902917DE101A8010C,
F546272B02917DE301A8010C,
F546272D02917DE501A8010C,
F546272F02917DE601A8010C,
F546273102917DE801A8010C,
F546273302917DE901A8010C,
);
isa = PBXSourcesBuildPhase;
};
F546270D02917D1501A8010C = {
buildActionMask = 2147483647;
files = (
F546271202917DBB01A8010C,
);
isa = PBXFrameworksBuildPhase;
};
F546270E02917D1501A8010C = {
buildActionMask = 2147483647;
files = (
);
isa = PBXRezBuildPhase;
};
F546270F02917D1501A8010C = {
buildPhases = (
F546270B02917D1501A8010C,
F546270C02917D1501A8010C,
F546270D02917D1501A8010C,
F546270E02917D1501A8010C,
);
buildSettings = {
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
LIBRARY_STYLE = STATIC;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_LIBTOOL_FLAGS = "";
OTHER_REZFLAGS = "";
PRODUCT_NAME = libResKnife.dylib;
REZ_EXECUTABLE = YES;
SECTORDER_FLAGS = "";
WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
};
dependencies = (
);
isa = PBXLibraryTarget;
name = libResKnife;
productInstallPath = /usr/local/lib;
productName = libResKnife;
productReference = F546271002917D1501A8010C;
shouldUseHeadermap = 0;
};
F546271002917D1501A8010C = {
isa = PBXLibraryReference;
path = libResKnife.dylib;
refType = 3;
};
F546271102917D2001A8010C = {
isa = PBXTargetDependency;
target = F546270F02917D1501A8010C;
};
F546271202917DBB01A8010C = {
fileRef = F5B5884A0156D40B01000001;
isa = PBXBuildFile;
settings = {
};
};
F546271302917DC501A8010C = {
fileRef = F5B588810156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271402917DC601A8010C = {
fileRef = F5B588820156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271502917DC701A8010C = {
fileRef = F5B588800156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271602917DC801A8010C = {
fileRef = F5B588840156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271702917DC901A8010C = {
fileRef = F5B588850156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271802917DCB01A8010C = {
fileRef = F5B588860156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271902917DCC01A8010C = {
fileRef = F5B588870156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271A02917DCD01A8010C = {
fileRef = F5B588880156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271B02917DCD01A8010C = {
fileRef = F5B588890156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271C02917DCE01A8010C = {
fileRef = F5B5888A0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271D02917DCF01A8010C = {
fileRef = F5B5888B0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271E02917DD101A8010C = {
fileRef = F5B5888C0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546271F02917DD101A8010C = {
fileRef = F5B5888D0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272002917DD201A8010C = {
fileRef = F5B5888E0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272102917DD301A8010C = {
fileRef = F5B5888F0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272202917DD301A8010C = {
fileRef = F5B588900156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272302917DD501A8010C = {
fileRef = F5B588910156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272402917DD601A8010C = {
fileRef = F5B588920156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272502917DD601A8010C = {
fileRef = F5B588930156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272602917DD701A8010C = {
fileRef = F5B588940156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272702917DE001A8010C = {
fileRef = F5B588A10156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272802917DE001A8010C = {
fileRef = F5B588A00156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272902917DE101A8010C = {
fileRef = F5B5889F0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272A02917DE201A8010C = {
fileRef = F5B5889E0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272B02917DE301A8010C = {
fileRef = F5B5889D0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272C02917DE401A8010C = {
fileRef = F5B5889C0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272D02917DE501A8010C = {
fileRef = F5B5889B0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272E02917DE601A8010C = {
fileRef = F5B5889A0156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546272F02917DE601A8010C = {
fileRef = F5B588990156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546273002917DE701A8010C = {
fileRef = F5B588980156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546273102917DE801A8010C = {
fileRef = F5B588970156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546273202917DE801A8010C = {
fileRef = F5B588960156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546273302917DE901A8010C = {
fileRef = F5B588950156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F546273402917E5601A8010C = {
fileRef = F546271002917D1501A8010C;
isa = PBXBuildFile;
settings = {
};
};
F54E6220021B6A0801A80001 = {
isa = PBXFileReference;
path = FindSheetController.h;
@ -853,6 +1194,7 @@
F5354437022674B401A80001,
F5DF1C090254C6BA01A80001,
F5B588750156D5CB01000001,
F546270F02917D1501A8010C,
F5B588D20156D78201000001,
F5B588EE0156DAF301000001,
F5B5890B0156DC2201000001,
@ -874,10 +1216,11 @@
F5B588110156D30301000001 = {
children = (
F5B588120156D30301000001,
F5B588740156D5CB01000001,
F57CEE0D0189C95101A8010B,
F5354436022674B301A80001,
F5DF1C080254C6BA01A80001,
F5B588740156D5CB01000001,
F546271002917D1501A8010C,
F5B588D10156D78201000001,
F5B588ED0156DAF301000001,
F5B589030156DC2201000001,
@ -1401,6 +1744,8 @@
F5B588490156D40B01000001 = {
children = (
F5B5884A0156D40B01000001,
F54625C6029174F601A8010C,
F54626490291750201A8010C,
F5B5884B0156D40B01000001,
F5B5884C0156D40B01000001,
F5B5884D0156D40B01000001,
@ -1645,6 +1990,7 @@
F5B5887A0156D5CB01000001,
);
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Versions/A/Frameworks\"";
LIBRARY_SEARCH_PATHS = Carbon;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
@ -1655,6 +2001,10 @@
WRAPPER_EXTENSION = app;
};
dependencies = (
F546271102917D2001A8010C,
F54627060291788401A8010C,
F54627070291788801A8010C,
F54627080291788A01A8010C,
);
isa = PBXApplicationTarget;
name = "ResKnife Carbon";
@ -1791,7 +2141,7 @@
buildActionMask = 2147483647;
files = (
F5B588CF0156D6D901000001,
F5B588D00156D6D901000001,
F54627050291767E01A8010C,
);
isa = PBXRezBuildPhase;
};
@ -2036,6 +2386,7 @@
F5B588A30156D6D901000001,
F5B588A40156D6D901000001,
F5B588A50156D6D901000001,
F54627040291767E01A8010C,
F5B588A60156D6D901000001,
);
isa = PBXGroup;
@ -2272,12 +2623,6 @@
settings = {
};
};
F5B588D00156D6D901000001 = {
fileRef = F5B588A50156D6D901000001;
isa = PBXBuildFile;
settings = {
};
};
F5B588D10156D78201000001 = {
isa = PBXBundleReference;
path = "Hex Editor.bundle";
@ -2369,6 +2714,7 @@
buildActionMask = 2147483647;
files = (
F5B588EC0156DA1601000001,
F546273402917E5601A8010C,
);
isa = PBXFrameworksBuildPhase;
};