aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-04-27 23:21:30 +0000
committerBibiko <bibiko@eva.mpg.de>2009-04-27 23:21:30 +0000
commit48f7edad7277e6b67f813020943267487f4663c4 (patch)
treed369c162b54e50c86ccddf4e7430823b5cd6da61 /Source
parentc69089a7abb022fc1e454ff2bf8297887b1fc2f1 (diff)
downloadsequelpro-48f7edad7277e6b67f813020943267487f4663c4.tar.gz
sequelpro-48f7edad7277e6b67f813020943267487f4663c4.tar.bz2
sequelpro-48f7edad7277e6b67f813020943267487f4663c4.zip
• improved MySQL Help GUI resize behaviour
• fixed some minor issues to detect http links in help descriptions • first steps to make SQL statements and see [HELP %] clickable
Diffstat (limited to 'Source')
-rw-r--r--Source/CustomQuery.m46
1 files changed, 41 insertions, 5 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 5afc918b..d735dc71 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -1357,6 +1357,9 @@ traps enter key and
}
}
+
+
+#pragma mark -
#pragma mark MySQL Help
@@ -1457,7 +1460,7 @@ traps enter key and
{
switch([helpNavigator selectedSegment])
{
- case 1:
+ case 1: // TOC
[self showHelpFor:@"contents"];
break;
}
@@ -1575,21 +1578,54 @@ traps enter key and
// detect and generate http links
aRange = NSMakeRange(0,0);
- int safeCnt = 0; // safety counter - not more thn 20 links allowed
+ int safeCnt = 0; // safety counter - not more than 200 loops allowed
while(1){
- aRange = [desc rangeOfRegex:@" ((https?|ftp:file)://.*?)\\s" options:RKLNoOptions inRange:NSMakeRange(aRange.location+aRange.length, [desc length]-aRange.location-aRange.length) capture:1 error:&err1];
+ aRange = [desc rangeOfRegex:@"\\s((https?|ftp:file)://.*?)\\s" options:RKLNoOptions inRange:NSMakeRange(aRange.location+aRange.length, [desc length]-aRange.location-aRange.length) capture:1 error:&err1];
if(aRange.location != NSNotFound) {
- if([[desc substringWithRange:aRange] hasSuffix:@"."] )
+ if([[desc substringWithRange:aRange] hasSuffix:@"."] || [[desc substringWithRange:aRange] hasSuffix:@")"])
aRange.length -= 1;
+ if([[desc substringWithRange:aRange] hasSuffix:@".)"] || [[desc substringWithRange:aRange] hasSuffix:@")."])
+ aRange.length -= 2;
aUrl = [desc substringWithRange:aRange];
[desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"<a href='%@'>%@</a>", aUrl, aUrl]];
}
else
break;
safeCnt++;
- if(safeCnt > 20)
+ if(safeCnt > 200)
+ break;
+ }
+ // detect and generate mysql links for "[HELP keyword]"
+ aRange = NSMakeRange(0,0);
+ safeCnt = 0;
+ while(1){
+ // TODO how to catch in HELP 'grant' last see [HELP SHOW GRANTS] ?? it's ridiculous
+ aRange = [desc rangeOfRegex:@"\\[HELP ([^ ]*?)\\]" options:RKLNoOptions inRange:NSMakeRange(aRange.location+aRange.length+53, [desc length]-53-aRange.location-aRange.length) capture:1 error:&err1];
+ if(aRange.location != NSNotFound) {
+ aUrl = [desc substringWithRange:aRange];
+ [desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"<a title='%@ “%@”' href='%@' class='internallink'>%@</a>", NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), aUrl, aUrl, aUrl]];
+ }
+ else
+ break;
+ safeCnt++;
+ if(safeCnt > 200)
break;
}
+ // detect and generate mysql links for capitalzed letters
+ // aRange = NSMakeRange(0,0);
+ // safeCnt = 0;
+ // while(1){
+ // aRange = [desc rangeOfRegex:@"(?<!\\w)([A-Z_]{2,}( [A-Z_]{2,})?)" options:RKLNoOptions inRange:NSMakeRange(aRange.location+aRange.length, [desc length]-aRange.location-aRange.length) capture:1 error:&err1];
+ // if(aRange.location != NSNotFound) {
+ // aUrl = [desc substringWithRange:aRange];
+ // [desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"<a title='%@ “%@”' href='%@' class='internallink'>%@</a>", NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), aUrl, aUrl, aUrl]];
+ // }
+ // else
+ // break;
+ // safeCnt++;
+ // if(safeCnt > 200)
+ // break;
+ // }
[theHelp appendString:@"<pre class='code'>"];
[theHelp appendString:desc];