The metrics of Courier have changed. That resulted in the offsets column being wrapped (the colon didn't fit in the line anymore). We now try to actually use Courier's size for some of the calculations instead of hardcoded magic numbers, but we should revisit this code.

This commit is contained in:
Uli Kusterer 2017-01-10 16:15:30 +01:00
parent 08670082ee
commit e83edced0e
6 changed files with 1776 additions and 93 deletions

View File

@ -1,48 +0,0 @@
{
IBClasses = (
{CLASS = AsciiTextView; LANGUAGE = ObjC; SUPERCLASS = HexEditorTextView; },
{
ACTIONS = {
copyASCII = id;
copyHex = id;
pasteAsASCII = id;
pasteAsHex = id;
pasteAsUnicode = id;
pasteFromHex = id;
};
CLASS = FirstResponder;
LANGUAGE = ObjC;
SUPERCLASS = NSObject;
},
{
CLASS = HexEditorDelegate;
LANGUAGE = ObjC;
OUTLETS = {
ascii = NSTextView;
controller = HexWindowController;
hex = NSTextView;
message = NSTextField;
offset = NSTextView;
};
SUPERCLASS = NSObject;
},
{CLASS = HexEditorTextView; LANGUAGE = ObjC; SUPERCLASS = NSTextView; },
{CLASS = HexTextView; LANGUAGE = ObjC; SUPERCLASS = HexEditorTextView; },
{
ACTIONS = {showFind = id; };
CLASS = HexWindowController;
LANGUAGE = ObjC;
OUTLETS = {
ascii = NSTextView;
copySubmenu = NSMenu;
hex = NSTextView;
hexDelegate = HexEditorDelegate;
message = NSTextField;
offset = NSTextView;
pasteSubmenu = NSMenu;
};
SUPERCLASS = NSWindowController;
}
);
IBVersion = 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>76 233 356 240 0 0 1600 1002 </string>
<key>IBEditorPositions</key>
<dict>
<key>24</key>
<string>239 475 202 137 0 0 1600 1002 </string>
<key>8</key>
<string>30 493 203 99 0 0 1600 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBLockedObjects</key>
<array>
<integer>45</integer>
<integer>47</integer>
<integer>48</integer>
<integer>42</integer>
<integer>44</integer>
<integer>46</integer>
<integer>43</integer>
</array>
<key>IBOldestOS</key>
<integer>2</integer>
<key>IBOpenObjects</key>
<array>
<integer>24</integer>
<integer>36</integer>
</array>
<key>IBSystem Version</key>
<string>8L127</string>
</dict>
</plist>

View File

@ -45,7 +45,7 @@
int row;
for( row = 0; row < rows; row++ )
[representation appendFormat:@"%08lX:", row * bytesPerRow];
[representation appendFormat:@"%08X:\n", row * bytesPerRow];
return representation;
}
@ -143,4 +143,4 @@
return rangeForUserTextChange;
}
@end
@end

View File

@ -73,7 +73,8 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource)
// insert the resources' data into the text fields
[self refreshData:[resource data]];
[[self window] setResizeIncrements:NSMakeSize(kWindowStepWidthPerChar * kWindowStepCharsPerStep, 1)];
CGFloat charWidth = [@"0" sizeWithAttributes: @{ NSFontAttributeName: [NSFont fontWithName: @"Courier" size: 12] }].width;
[[self window] setResizeIncrements:NSMakeSize((charWidth * 3.0) * kWindowStepCharsPerStep, 1)];
// min 346, step 224, norm 570, step 224, max 794
// here because we don't want these notifications until we have a window! (Only register for notifications on the resource we're editing)
@ -91,12 +92,13 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource)
{
int width = [(NSWindow *)[notification object] frame].size.width;
int oldBytesPerRow = bytesPerRow;
bytesPerRow = (((width - (kWindowStepWidthPerChar * kWindowStepCharsPerStep) - 122) / (kWindowStepWidthPerChar * kWindowStepCharsPerStep)) + 1) * kWindowStepCharsPerStep;
CGFloat charWidth = [@"0" sizeWithAttributes: @{ NSFontAttributeName: [NSFont fontWithName: @"Courier" size: 12] }].width;
bytesPerRow = (((width - ((charWidth * 3.0) * kWindowStepCharsPerStep) - 122) / (kWindowStepWidthPerChar * kWindowStepCharsPerStep)) + 1) * kWindowStepCharsPerStep;
if(bytesPerRow != oldBytesPerRow)
[offset setString:[hexDelegate offsetRepresentation:[resource data]]];
[[hex enclosingScrollView] setFrameSize:NSMakeSize((bytesPerRow * 21) + 5, [[hex enclosingScrollView] frame].size.height)];
[[ascii enclosingScrollView] setFrameOrigin:NSMakePoint((bytesPerRow * 21) + 95, 20)];
[[ascii enclosingScrollView] setFrameSize:NSMakeSize((bytesPerRow * 7) + 28, [[ascii enclosingScrollView] frame].size.height)];
[[hex enclosingScrollView] setFrameSize:NSMakeSize((bytesPerRow * (charWidth * 3.0)) + 5+5, [[hex enclosingScrollView] frame].size.height)];
[[ascii enclosingScrollView] setFrameOrigin:NSMakePoint((bytesPerRow * (charWidth * 3.0)) + 95, 20)];
[[ascii enclosingScrollView] setFrameSize:NSMakeSize((bytesPerRow * charWidth) + 28, [[ascii enclosingScrollView] frame].size.height)];
}
- (void)windowDidBecomeKey:(NSNotification *)notification
@ -230,6 +232,10 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource)
NSMutableParagraphStyle *paragraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraph setLineBreakMode:NSLineBreakByCharWrapping];
NSDictionary *dictionary = [NSDictionary dictionaryWithObject:paragraph forKey:NSParagraphStyleAttributeName];
NSMutableParagraphStyle *hexParagraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
//[hexParagraph setLineBreakMode:NSLineBreakByCharWrapping];
NSDictionary *hexDictionary = [NSDictionary dictionaryWithObject:hexParagraph forKey:NSParagraphStyleAttributeName];
// do stuff with data
[offset setString:[hexDelegate offsetRepresentation:data]];
@ -240,7 +246,7 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource)
// apply attributes
[[offset textStorage] addAttributes:dictionary range:NSMakeRange(0, [[offset textStorage] length])];
[[hex textStorage] addAttributes:dictionary range:NSMakeRange(0, [[hex textStorage] length])];
[[hex textStorage] addAttributes:hexDictionary range:NSMakeRange(0, [[hex textStorage] length])];
[[ascii textStorage] addAttributes:dictionary range:NSMakeRange(0, [[ascii textStorage] length])];
// restore selections (this is the dumbest way to do it, but it'll do for now)
@ -314,4 +320,4 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource)
return byteRange;
}
@end
@end