aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableContentDelegate.m
diff options
context:
space:
mode:
authorStuart Connolly <stuart02@gmail.com>2014-01-14 19:05:29 +0000
committerStuart Connolly <stuart02@gmail.com>2014-01-14 19:05:29 +0000
commitfc8cc239ab276cf0fc7a7b9ed77369aa9666e06a (patch)
tree568029c742fb30ddaa18450f0d48e1aa6037993e /Source/SPTableContentDelegate.m
parent12c3d328170a182a18280e9c62f78144095adcc0 (diff)
downloadsequelpro-fc8cc239ab276cf0fc7a7b9ed77369aa9666e06a.tar.gz
sequelpro-fc8cc239ab276cf0fc7a7b9ed77369aa9666e06a.tar.bz2
sequelpro-fc8cc239ab276cf0fc7a7b9ed77369aa9666e06a.zip
Add an option to display binary data as hex, while displaying it in blue to distinguish from string data of similar content.
Diffstat (limited to 'Source/SPTableContentDelegate.m')
-rw-r--r--Source/SPTableContentDelegate.m34
1 files changed, 24 insertions, 10 deletions
diff --git a/Source/SPTableContentDelegate.m b/Source/SPTableContentDelegate.m
index 53f65468..ac2d69ae 100644
--- a/Source/SPTableContentDelegate.m
+++ b/Source/SPTableContentDelegate.m
@@ -279,12 +279,11 @@
isFieldEditable = [[editStatus objectAtIndex:0] integerValue] == 1;
}
- NSString *fieldType = nil;
NSUInteger fieldLength = 0;
NSString *fieldEncoding = nil;
BOOL allowNULL = YES;
- fieldType = [columnDefinition objectForKey:@"type"];
+ NSString *fieldType = [columnDefinition objectForKey:@"type"];
if ([columnDefinition objectForKey:@"char_length"]) {
fieldLength = [[columnDefinition objectForKey:@"char_length"] integerValue];
@@ -298,7 +297,7 @@
fieldEncoding = [columnDefinition objectForKey:@"charset_name"];
}
- if(fieldEditor) [fieldEditor release], fieldEditor = nil;
+ if (fieldEditor) [fieldEditor release], fieldEditor = nil;
fieldEditor = [[SPFieldEditorController alloc] init];
@@ -309,15 +308,19 @@
nil]];
[fieldEditor setTextMaxLength:fieldLength];
- [fieldEditor setFieldType:(fieldType==nil) ? @"" : fieldType];
- [fieldEditor setFieldEncoding:(fieldEncoding==nil) ? @"" : fieldEncoding];
+ [fieldEditor setFieldType:fieldType == nil ? @"" : fieldType];
+ [fieldEditor setFieldEncoding:fieldEncoding == nil ? @"" : fieldEncoding];
[fieldEditor setAllowNULL:allowNULL];
-
+
id cellValue = [tableValues cellDataAtRow:rowIndex column:[[tableColumn identifier] integerValue]];
if ([cellValue isNSNull]) {
cellValue = [NSString stringWithString:[prefs objectForKey:SPNullValue]];
}
+
+ if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"binary"] && [prefs boolForKey:SPDisplayBinaryDataAsHex]) {
+ [fieldEditor setTextMaxLength:[[self tableView:tableContentView objectValueForTableColumn:tableColumn row:rowIndex] length]];
+ }
NSInteger editedColumn = 0;
@@ -467,6 +470,7 @@
BOOL cellIsNullOrUnloaded = NO;
BOOL cellIsLinkCell = [cell isMemberOfClass:[SPTextAndLinkCell class]];
+
NSUInteger columnIndex = [[tableColumn identifier] integerValue];
// If user wants to edit 'cell' set text color to black and return to avoid
@@ -494,20 +498,30 @@
else {
cellIsNullOrUnloaded = [tableValues cellIsNullOrUnloadedAtRow:rowIndex column:columnIndex];
}
-
-
+
if (cellIsNullOrUnloaded) {
- [cell setTextColor:lightGrayColor];
+ [cell setTextColor:rowIndex == [tableContentView selectedRow] ? whiteColor : lightGrayColor];
}
else {
[cell setTextColor:blackColor];
}
+ NSDictionary *columnDefinition = [[(id <SPDatabaseContentViewDelegate>)[tableContentView delegate] dataColumnDefinitions] objectAtIndex:columnIndex];
+
+ NSString *columnType = [columnDefinition objectForKey:@"typegrouping"];
+
+ // Find a more reliable way of doing this check
+ if ([columnType isEqualToString:@"binary"] && [[self tableView:tableContentView objectValueForTableColumn:tableColumn row:rowIndex] hasPrefix:@"0x"]) {
+
+ [cell setTextColor:rowIndex == [tableContentView selectedRow] ? whiteColor : blueColor];
+ }
+
// Disable link arrows for the currently editing row and for any NULL or unloaded cells
if (cellIsLinkCell) {
if (cellIsNullOrUnloaded || [tableView editedRow] == rowIndex) {
[cell setLinkActive:NO];
- } else {
+ }
+ else {
[cell setLinkActive:YES];
}
}