From 48f7edad7277e6b67f813020943267487f4663c4 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 27 Apr 2009 23:21:30 +0000 Subject: =?UTF-8?q?=E2=80=A2=20improved=20MySQL=20Help=20GUI=20resize=20be?= =?UTF-8?q?haviour=20=E2=80=A2=20fixed=20some=20minor=20issues=20to=20dete?= =?UTF-8?q?ct=20http=20links=20in=20help=20descriptions=20=E2=80=A2=20firs?= =?UTF-8?q?t=20steps=20to=20make=20SQL=20statements=20and=20see=20[HELP=20?= =?UTF-8?q?%]=20clickable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CustomQuery.m | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'Source/CustomQuery.m') 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:@"%@", 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:@"%@", 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:@"(?%@", NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), aUrl, aUrl, aUrl]]; + // } + // else + // break; + // safeCnt++; + // if(safeCnt > 200) + // break; + // } [theHelp appendString:@"
"];
 			[theHelp appendString:desc];
-- 
cgit v1.2.3