aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Resources/sequel-pro-table-info-print-template.html4
-rw-r--r--Source/SPExtendedTableInfo.m27
2 files changed, 24 insertions, 7 deletions
diff --git a/Resources/sequel-pro-table-info-print-template.html b/Resources/sequel-pro-table-info-print-template.html
index 30198ec2..acc13ad3 100644
--- a/Resources/sequel-pro-table-info-print-template.html
+++ b/Resources/sequel-pro-table-info-print-template.html
@@ -142,8 +142,10 @@
<p><em>{{i.comments}}</em></p>
{% /if %}
+ {% if i.createSyntax > 0 %}
<h2>Create Syntax</h2>
- <pre>{{i.createSyntax}}</pre>
+ {{i.createSyntax}}
+ {% /if %}
</body>
</html>
diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m
index 852b1007..30741424 100644
--- a/Source/SPExtendedTableInfo.m
+++ b/Source/SPExtendedTableInfo.m
@@ -171,11 +171,11 @@
- (IBAction)resetAutoIncrement:(id)sender
{
-
- if([sender tag] == 1) {
+ if ([sender tag] == 1) {
[tableRowAutoIncrement setEditable:YES];
[tableRowAutoIncrement selectText:nil];
- } else {
+ }
+ else {
[tableRowAutoIncrement setEditable:NO];
[tableSourceInstance resetAutoIncrement:sender];
}
@@ -189,12 +189,12 @@
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command
{
-
// Listen to ESC to abort editing of auto increment input field
if (command == @selector(cancelOperation:) && control == tableRowAutoIncrement) {
[tableRowAutoIncrement abortEditing];
return YES;
}
+
return NO;
}
@@ -368,7 +368,7 @@
}
/**
- *
+ * Returns a dictionary describing the information of the table to be used for printing purposes.
*/
- (NSDictionary *)tableInformationForPrinting
{
@@ -391,7 +391,22 @@
[tableInfo setObject:[self _formatValueWithKey:@"Data_free" inDictionary:statusFields] forKey:@"sizeFree"];
[tableInfo setObject:[tableCommentsTextView string] forKey:@"comments"];
- [tableInfo setObject:[tableCreateSyntaxTextView string] forKey:@"createSyntax"];
+
+ NSError *error = nil;
+ NSArray *HTMLExcludes = [NSArray arrayWithObjects:@"doctype", @"html", @"head", @"body", @"xml", nil];
+
+ NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType, NSDocumentTypeDocumentAttribute, HTMLExcludes, NSExcludedElementsDocumentAttribute, nil];
+ NSData *HTMLData = [[tableCreateSyntaxTextView textStorage] dataFromRange:NSMakeRange(0, [[tableCreateSyntaxTextView string] length]) documentAttributes:attributes error:&error];
+
+ if (error != nil) {
+ NSLog(@"Error generating table's create syntax HTML for printing. Excluding from print out. Error was: %@", [error localizedDescription]);
+
+ return tableInfo;
+ }
+
+ NSString *HTMLString = [[[NSString alloc] initWithData:HTMLData encoding:NSUTF8StringEncoding] autorelease];
+
+ [tableInfo setObject:HTMLString forKey:@"createSyntax"];
return tableInfo;
}