From 56817be6cc46742b75e23b021787eb006829b53f Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 27 May 2018 21:14:01 +0200 Subject: Internal Refactoring: Move MySQL Help viewer into own xib with own controller --- .../Querying & Preparation.m | 1 + Interfaces/English.lproj/DBView.xib | 196 +------- Interfaces/English.lproj/HelpViewer.xib | 213 +++++++++ Resources/Templates/SPMySQLHelpTemplate.html | 19 +- Source/SPCustomQuery.h | 40 -- Source/SPCustomQuery.m | 531 +-------------------- Source/SPDatabaseDocument.h | 4 + Source/SPDatabaseDocument.m | 14 +- Source/SPHelpViewerClient.h | 66 +++ Source/SPHelpViewerClient.m | 262 ++++++++++ Source/SPHelpViewerController.h | 99 ++++ Source/SPHelpViewerController.m | 415 ++++++++++++++++ Source/SPTextView.m | 3 +- sequel-pro.xcodeproj/project.pbxproj | 24 + 14 files changed, 1130 insertions(+), 757 deletions(-) create mode 100644 Interfaces/English.lproj/HelpViewer.xib create mode 100644 Source/SPHelpViewerClient.h create mode 100644 Source/SPHelpViewerClient.m create mode 100644 Source/SPHelpViewerController.h create mode 100644 Source/SPHelpViewerController.m diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m index ce52f397..16ff22f3 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m @@ -100,6 +100,7 @@ NSData *escapedData; if (includeQuotes) { +#warning This code assumes that the encoding cData is in is still ASCII-compatible which may not be the case (e.g. for UTF16, EBCDIC) // Add quotes if requested escBuffer[0] = '\''; escBuffer[escapedLength+1] = '\''; diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 6d2e2cbd..ac4c5f78 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -4,7 +4,6 @@ - @@ -38,6 +37,7 @@ + @@ -4003,190 +4003,6 @@ Gw - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4551,12 +4367,6 @@ Gw - - - - - - @@ -4846,6 +4656,7 @@ Gw + @@ -5178,9 +4989,6 @@ Gw - - - diff --git a/Interfaces/English.lproj/HelpViewer.xib b/Interfaces/English.lproj/HelpViewer.xib new file mode 100644 index 00000000..4ec08105 --- /dev/null +++ b/Interfaces/English.lproj/HelpViewer.xib @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Resources/Templates/SPMySQLHelpTemplate.html b/Resources/Templates/SPMySQLHelpTemplate.html index 548c30df..c5e59e88 100644 --- a/Resources/Templates/SPMySQLHelpTemplate.html +++ b/Resources/Templates/SPMySQLHelpTemplate.html @@ -2,12 +2,12 @@ - + {{title}} -%@ +{{body}} diff --git a/Source/SPCustomQuery.h b/Source/SPCustomQuery.h index 24695ba2..f06b63dc 100644 --- a/Source/SPCustomQuery.h +++ b/Source/SPCustomQuery.h @@ -31,17 +31,6 @@ #import "SPDatabaseContentViewDelegate.h" -#import - -#define SP_HELP_TOC_SEARCH_STRING @"contents" -#define SP_HELP_SEARCH_IN_MYSQL 0 -#define SP_HELP_SEARCH_IN_PAGE 1 -#define SP_HELP_SEARCH_IN_WEB 2 -#define SP_HELP_GOBACK_BUTTON 0 -#define SP_HELP_SHOW_TOC_BUTTON 1 -#define SP_HELP_GOFORWARD_BUTTON 2 -#define SP_HELP_NOT_AVAILABLE @"__no_help_available" - #define SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG 100001 #define SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG 100000 #define SP_FAVORITE_HEADER_MENUITEM_TAG 200000 @@ -122,12 +111,6 @@ #ifndef SP_CODA IBOutlet NSMenuItem *previousHistoryMenuItem; IBOutlet NSMenuItem *nextHistoryMenuItem; - IBOutlet NSWindow *helpWebViewWindow; - IBOutlet WebView *helpWebView; - IBOutlet NSSearchField *helpSearchField; - IBOutlet NSSearchFieldCell *helpSearchFieldCell; - IBOutlet NSSegmentedControl *helpNavigator; - IBOutlet NSSegmentedControl *helpTargetSelector; #endif IBOutlet NSButton *queryInfoButton; @@ -145,17 +128,10 @@ NSArray *currentQueryRanges; BOOL currentQueryBeforeCaret; - NSString *mySQLversion; NSTableColumn *sortColumn; NSUInteger queryStartPosition; -#ifndef SP_CODA - NSUInteger helpTarget; - WebHistory *helpHistory; - NSString *helpHTMLTemplate; -#endif - SPDataStorage *resultData; pthread_mutex_t resultDataLock; NSArray *cqColumnDefinition; @@ -213,17 +189,6 @@ - (IBAction)chooseQueryHistory:(id)sender; - (IBAction)closeSheet:(id)sender; - (IBAction)gearMenuItemSelected:(id)sender; -#ifndef SP_CODA -- (IBAction)showHelpForCurrentWord:(id)sender; -- (IBAction)showHelpForSearchString:(id)sender; -- (IBAction)helpSegmentDispatcher:(id)sender; -- (IBAction)helpTargetDispatcher:(id)sender; -- (IBAction)helpSearchFindNextInPage:(id)sender; -- (IBAction)helpSearchFindPreviousInPage:(id)sender; -- (IBAction)helpSelectHelpTargetMySQL:(id)sender; -- (IBAction)helpSelectHelpTargetPage:(id)sender; -- (IBAction)helpSelectHelpTargetWeb:(id)sender; -#endif - (IBAction)filterQueryFavorites:(id)sender; - (IBAction)filterQueryHistory:(id)sender; - (IBAction)saveQueryHistory:(id)sender; @@ -268,11 +233,6 @@ #ifndef SP_CODA // MySQL Help - (void)showAutoHelpForCurrentWord:(id)sender; -- (NSString *)getHTMLformattedMySQLHelpFor:(NSString *)searchString calledByAutoHelp:(BOOL)autoHelp; -- (void)showHelpFor:(NSString *)aString addToHistory:(BOOL)addToHistory calledByAutoHelp:(BOOL)autoHelp; -- (void)helpTargetValidation; -- (void)openMySQLonlineDocumentationWithString:(NSString *)searchString; -- (NSWindow *)helpWebViewWindow; #endif - (void)setMySQLversion:(NSString *)theVersion; diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index e8c1d6ad..62ff3e18 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -61,6 +61,8 @@ #import "SPBundleHTMLOutputController.h" #endif #import "SPFunctions.h" +#import "SPHelpViewerClient.h" +#import "SPHelpViewerController.h" #import #import @@ -68,10 +70,10 @@ @interface SPCustomQuery () - (id)_resultDataItemAtRow:(NSInteger)row columnIndex:(NSUInteger)column preserveNULLs:(BOOL)preserveNULLs asPreview:(BOOL)asPreview; -+ (NSString *)linkToHelpTopic:(NSString *)aTopic; - (void)documentWillClose:(NSNotification *)notification; - (void)queryFavoritesHaveBeenUpdated:(NSNotification *)notification; - (void)historyItemsHaveBeenUpdated:(NSNotification *)notification; +- (void)helpWindowClosedByUser:(NSNotification *)notification; @end @@ -2830,221 +2832,14 @@ #endif -#pragma mark - -#pragma mark MySQL Help - /** - * Set the MySQL version as X.Y for Help window title and online search + * Set the MySQL version as X.Y */ - (void)setMySQLversion:(NSString *)theVersion { - mySQLversion = [[theVersion substringToIndex:3] retain]; - [textView setConnection:mySQLConnection withVersion:[[[mySQLversion componentsSeparatedByString:@"."] objectAtIndex:0] integerValue]]; -} - -#ifndef SP_CODA -/** - * Return the Help window. - */ -- (NSWindow *)helpWebViewWindow -{ - return helpWebViewWindow; + [textView setConnection:mySQLConnection withVersion:[[[[theVersion substringToIndex:3] componentsSeparatedByString:@"."] objectAtIndex:0] integerValue]]; } -/** - * Show the data for "HELP 'searchString'". - */ -- (void)showHelpFor:(NSString *)searchString addToHistory:(BOOL)addToHistory calledByAutoHelp:(BOOL)autoHelp -{ - - // If there's no search string, show nothing if called by autohelp, and the index otherwise - if (![searchString length]) { - if (autoHelp) return; - searchString = SP_HELP_TOC_SEARCH_STRING; - } - - NSString *helpString = [self getHTMLformattedMySQLHelpFor:searchString calledByAutoHelp:autoHelp]; - - if(autoHelp && [helpString isEqualToString:SP_HELP_NOT_AVAILABLE]) { - [helpWebViewWindow orderOut:nil]; - return; - } - - // Order out resp. init the Help window if not visible - if(![helpWebViewWindow isVisible]) - { - // set title of the Help window - [helpWebViewWindow setTitle:[NSString stringWithFormat:@"%@ (%@ %@)", NSLocalizedString(@"MySQL Help", @"mysql help"), NSLocalizedString(@"version", @"version"), mySQLversion]]; - - // init goback/forward buttons - if([[helpWebView backForwardList] backListCount] < 1) - { - [helpNavigator setEnabled:NO forSegment:SP_HELP_GOBACK_BUTTON]; - [helpNavigator setEnabled:NO forSegment:SP_HELP_GOFORWARD_BUTTON]; - } else { - [helpNavigator setEnabled:[[helpWebView backForwardList] backListCount] forSegment:SP_HELP_GOBACK_BUTTON]; - [helpNavigator setEnabled:[[helpWebView backForwardList] forwardListCount] forSegment:SP_HELP_GOFORWARD_BUTTON]; - } - - // set default to search in MySQL help - helpTarget = SP_HELP_SEARCH_IN_MYSQL; - [helpTargetSelector setSelectedSegment:SP_HELP_SEARCH_IN_MYSQL]; - [self helpTargetValidation]; - - // order out Help window if Help is available - if(![helpString isEqualToString:SP_HELP_NOT_AVAILABLE]) - [helpWebViewWindow orderFront:helpWebView]; - } - - // close Help window if no Help available - if([helpString isEqualToString:SP_HELP_NOT_AVAILABLE]) - [helpWebViewWindow close]; - - if(![helpString length]) return; - - // add searchString to history list - if(addToHistory) - { - WebHistoryItem *aWebHistoryItem = [[WebHistoryItem alloc] initWithURLString:[NSString stringWithFormat:@"applewebdata://%@", searchString] title:searchString lastVisitedTimeInterval:[[NSDate date] timeIntervalSinceDate:[NSDate distantFuture]]]; - [[helpWebView backForwardList] addItem:aWebHistoryItem]; - [aWebHistoryItem release]; - } - - // validate goback/forward buttons - [helpNavigator setEnabled:[[helpWebView backForwardList] backListCount] forSegment:SP_HELP_GOBACK_BUTTON]; - [helpNavigator setEnabled:[[helpWebView backForwardList] forwardListCount] forSegment:SP_HELP_GOFORWARD_BUTTON]; - - // load HTML formatted help into the webview - [[helpWebView mainFrame] loadHTMLString:helpString baseURL:nil]; -} - -/** - * Show the data for "HELP 'search word'" according to helpTarget - */ -- (IBAction)showHelpForSearchString:(id)sender -{ - NSString *searchString = [[helpSearchField stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - switch(helpTarget) - { - case SP_HELP_SEARCH_IN_PAGE: - if(![helpWebView searchFor:searchString direction:YES caseSensitive:NO wrap:YES]) - if([searchString length]) NSBeep(); - break; - case SP_HELP_SEARCH_IN_WEB: - if(![searchString length]) - break; - [self openMySQLonlineDocumentationWithString:searchString]; - break; - case SP_HELP_SEARCH_IN_MYSQL: - [self showHelpFor:searchString addToHistory:YES calledByAutoHelp:NO]; - break; - } -} - -/** - * Show the Help for the selected text in the webview - */ -- (IBAction)showHelpForWebViewSelection:(id)sender -{ - [self showHelpFor:[[helpWebView selectedDOMRange] text] addToHistory:YES calledByAutoHelp:NO]; -} - -/* - * Show MySQL's online documentation for the selected text in the webview - */ -- (IBAction)searchInDocForWebViewSelection:(id)sender -{ - NSString *searchString = [[[helpWebView selectedDOMRange] text] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - if(![searchString length]) - { - NSBeep(); - return; - } - [self openMySQLonlineDocumentationWithString:searchString]; -} - - -/** - * Show the data for "HELP 'currentWord'" - */ -- (IBAction)showHelpForCurrentWord:(id)sender -{ - NSString *searchString = [[sender string] substringWithRange:[sender getRangeForCurrentWord]]; - [self showHelpFor:searchString addToHistory:YES calledByAutoHelp:NO]; -} - -/** - * Find Next/Previous in current page - */ -- (IBAction)helpSearchFindNextInPage:(id)sender -{ - if(helpTarget == SP_HELP_SEARCH_IN_PAGE) - if(![helpWebView searchFor:[[helpSearchField stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] direction:YES caseSensitive:NO wrap:YES]) - NSBeep(); -} - -- (IBAction)helpSearchFindPreviousInPage:(id)sender -{ - if(helpTarget == SP_HELP_SEARCH_IN_PAGE) - if(![helpWebView searchFor:[[helpSearchField stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] direction:NO caseSensitive:NO wrap:YES]) - NSBeep(); -} - -/** - * Navigation for back/TOC/forward - */ -- (IBAction)helpSegmentDispatcher:(id)sender -{ - switch([helpNavigator selectedSegment]) - { - case SP_HELP_GOBACK_BUTTON: - [helpWebView goBack]; - break; - case SP_HELP_SHOW_TOC_BUTTON: - [self showHelpFor:SP_HELP_TOC_SEARCH_STRING addToHistory:YES calledByAutoHelp:NO]; - break; - case SP_HELP_GOFORWARD_BUTTON: - [helpWebView goForward]; - break; - } - - // validate goback and goforward buttons according history - [helpNavigator setEnabled:[[helpWebView backForwardList] backListCount] forSegment:SP_HELP_GOBACK_BUTTON]; - [helpNavigator setEnabled:[[helpWebView backForwardList] forwardListCount] forSegment:SP_HELP_GOFORWARD_BUTTON]; - -} - -/** - * Set helpTarget according user choice via mouse and keyboard short-cuts. - */ -- (IBAction)helpSelectHelpTargetMySQL:(id)sender -{ - helpTarget = SP_HELP_SEARCH_IN_MYSQL; - [helpTargetSelector setSelectedSegment:SP_HELP_SEARCH_IN_MYSQL]; - [self helpTargetValidation]; -} - -- (IBAction)helpSelectHelpTargetPage:(id)sender -{ - helpTarget = SP_HELP_SEARCH_IN_PAGE; - [helpTargetSelector setSelectedSegment:SP_HELP_SEARCH_IN_PAGE]; - [self helpTargetValidation]; -} - -- (IBAction)helpSelectHelpTargetWeb:(id)sender -{ - helpTarget = SP_HELP_SEARCH_IN_WEB; - [helpTargetSelector setSelectedSegment:SP_HELP_SEARCH_IN_WEB]; - [self helpTargetValidation]; -} - -- (IBAction)helpTargetDispatcher:(id)sender -{ - helpTarget = [helpTargetSelector selectedSegment]; - [self helpTargetValidation]; -} -#endif - - (IBAction)showCompletionList:(id)sender { NSRange insertRange = NSMakeRange([textView selectedRange].location, 0); @@ -3068,294 +2863,22 @@ - (void)showAutoHelpForCurrentWord:(id)sender { NSString *searchString = [[sender string] substringWithRange:[sender getRangeForCurrentWord]]; - [self showHelpFor:searchString addToHistory:YES calledByAutoHelp:YES]; -} - -/** - * Control the help search field behaviour. - */ -- (void)helpTargetValidation -{ - switch(helpTarget) - { - case SP_HELP_SEARCH_IN_PAGE: - case SP_HELP_SEARCH_IN_WEB: - [helpSearchFieldCell setSendsWholeSearchString:YES]; - break; - case SP_HELP_SEARCH_IN_MYSQL: - [helpSearchFieldCell setSendsWholeSearchString:NO]; - break; - } -} - -- (void)openMySQLonlineDocumentationWithString:(NSString *)searchString -{ - NSString *version = nil; - if([[mySQLversion stringByReplacingOccurrencesOfString:@"." withString:@""] integerValue] < 42) - version = @"4.1"; - else - version = [NSString stringWithString:mySQLversion]; - - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: - [[NSString stringWithFormat: - SPMySQLSearchURL, - version, - NSLocalizedString(@"en", @"MySQL search language code - eg in http://search.mysql.com/search?q=select&site=refman-50&lr=lang_en"), - searchString] - stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]]; -} - -/** - * Return the help string HTML formatted from executing "HELP 'searchString'". - * If more than one help topic was found return a link list. - */ -- (NSString *)getHTMLformattedMySQLHelpFor:(NSString *)searchString calledByAutoHelp:(BOOL)autoHelp -{ - - if(![searchString length]) return @""; - - // Don't escape % when being used as a wildcard, but escape it when it's being used by itself. - if ([searchString isEqualToString:@"%"]) searchString = @"\\%"; - - NSRange aRange; - SPMySQLResult *theResult = nil; - NSDictionary *tableDetails; - NSMutableString *theHelp = [NSMutableString string]; - - [theHelp setString:@""]; - - // search via: HELP 'searchString' - theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"HELP '%@'", [searchString stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]]; - if ([mySQLConnection queryErrored]) - { - // if an error or HELP is not supported fall back to online search but - // don't open it if autoHelp is enabled - if(!autoHelp) - [self openMySQLonlineDocumentationWithString:searchString]; - - [helpWebViewWindow close]; - return SP_HELP_NOT_AVAILABLE; - } - - // nothing found? - if(![theResult numberOfRows]) { - - // try to search via: HELP 'searchString%' - theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"HELP '%@%%'", [searchString stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]]; - - // really nothing found? - if(![theResult numberOfRows]) - return [NSString stringWithFormat:@"%@", NSLocalizedString(@"No results found.", @"Mysql Help Viewer : Search : No results")]; - } - - // Ensure rows are returned as strings to prevent data problems with older 4.1 servers - [theResult setReturnDataAsStrings:YES]; - - tableDetails = [[NSDictionary alloc] initWithDictionary:[theResult getRowAsDictionary]]; - - if ([tableDetails objectForKey:@"description"]) { // one single help topic found - if ([tableDetails objectForKey:@"name"]) { - [theHelp appendString:@"

"]; - [theHelp appendString:[[[tableDetails objectForKey:@"name"] copy] autorelease]]; - [theHelp appendString:@"

"]; - - } - if ([tableDetails objectForKey:@"description"]) { - NSMutableString *desc = [NSMutableString string]; - NSError *err1 = NULL; - NSString *aUrl; - - [desc setString:[[[tableDetails objectForKey:@"description"] copy] autorelease]]; - - //[desc replaceOccurrencesOfString:[searchString uppercaseString] withString:[NSString stringWithFormat:@"%@", [searchString uppercaseString]] options:NSLiteralSearch range:NSMakeRange(0,[desc length])]; - - // detect and generate http links - aRange = NSMakeRange(0,0); - NSInteger safeCnt = 0; // safety counter - not more than 200 loops allowed - while(1){ - aRange = [desc rangeOfRegex:@"\\s((https?|ftp|file)://.*?html)" options:RKLNoOptions inRange:NSMakeRange(NSMaxRange(aRange), [desc length]-aRange.location-aRange.length) capture:1 error:&err1]; - if(aRange.location != NSNotFound) { - aUrl = [desc substringWithRange:aRange]; - [desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"%@", aUrl, aUrl]]; - } - else - break; - safeCnt++; - if(safeCnt > 200) - break; - } - - // Detect and generate cross-links. First, handle the old-style [HELP ...] text. - [desc replaceOccurrencesOfRegex:@"(\\[HELP ([^\\]]*?)\\]" withString:[SPCustomQuery linkToHelpTopic:@"$1"]]; - - // Handle "see [...]" and "in [...]"-style 5.x links. - //look-behind won't work here because of the \s+ - [desc replaceOccurrencesOfRegex:@"(See|see|In|in|and)\\s+\\[(?:HELP\\s+)?([^\\]]*?)\\]" withString:[NSString stringWithFormat:@"$1 %@",[SPCustomQuery linkToHelpTopic:@"$2"]]]; - - [theHelp appendFormat:@"
%@
", desc]; - } - // are examples available? - if([tableDetails objectForKey:@"example"]){ - NSString *examples = [[[tableDetails objectForKey:@"example"] copy] autorelease]; - if([examples length]) - [theHelp appendFormat:@"
%1$@
%2$@
",NSLocalizedString(@"Example:",@"Mysql Help Viewer : Help Topic: Example section title"), examples]; - - } - } else { // list all found topics - - // check if HELP 'contents' is called - if(![searchString isEqualToString:SP_HELP_TOC_SEARCH_STRING]) - [theHelp appendFormat:@"
%@
", [NSString stringWithFormat:NSLocalizedString(@"Help topics for “%@”", @"MySQL Help Viewer : Results list : Page title"), searchString]]; - else - [theHelp appendFormat:@"
%@:
", NSLocalizedString(@"MySQL Help – Categories", @"mysql help categories")]; - - // iterate through all found rows and print them as HTML ul/li list - [theHelp appendString:@"
    "]; - [theResult setDefaultRowReturnType:SPMySQLResultRowAsArray]; - for (NSArray *eachRow in theResult) { - NSString *topic = [eachRow objectAtIndex:[eachRow count]-2]; - [theHelp appendFormat:@"
  • %@
  • ",[SPCustomQuery linkToHelpTopic:topic]]; - } - [theHelp appendString:@"
"]; - } - - [tableDetails release]; - - return [NSString stringWithFormat:helpHTMLTemplate, theHelp]; -} - -+ (NSString *)linkToHelpTopic:(NSString *)aTopic -{ - NSString *linkTitle = [NSString stringWithFormat:NSLocalizedString(@"Show MySQL help for “%@”", @"MySQL Help Viewer : Results list : Link tooltip"),aTopic]; - return [NSString stringWithFormat:@"%1$@", aTopic, linkTitle]; -} - -#pragma mark - -#pragma mark WebView delegate methods - -/** - * Link detector: If user clicked at an http link open it in the default browser, - * otherwise search for it in the MySQL help. Additionally handle back/forward events from - * keyboard and context menu. - */ -- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id)listener -{ - NSInteger navigationType = [[actionInformation objectForKey:WebActionNavigationTypeKey] integerValue]; - - if([[[request URL] scheme] isEqualToString:@"applewebdata"] && navigationType == WebNavigationTypeLinkClicked){ - [self showHelpFor:[[[request URL] path] lastPathComponent] addToHistory:YES calledByAutoHelp:NO]; - [listener ignore]; - } else { - if (navigationType == WebNavigationTypeOther) { - // catch reload event - // if([[[actionInformation objectForKey:WebActionOriginalURLKey] absoluteString] isEqualToString:@"about:blank"]) - // [listener use]; - // else - [listener use]; - } else if (navigationType == WebNavigationTypeLinkClicked) { - // show http in browser - [[NSWorkspace sharedWorkspace] openURL:[actionInformation objectForKey:WebActionOriginalURLKey]]; - [listener ignore]; - } else if (navigationType == WebNavigationTypeBackForward) { - // catch back/forward events from contextual menu - [self showHelpFor:[[[[actionInformation objectForKey:WebActionOriginalURLKey] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding] addToHistory:NO calledByAutoHelp:NO]; - [listener ignore]; - } else if (navigationType == WebNavigationTypeReload) { - // just in case - [listener ignore]; - } else { - // Ignore WebNavigationTypeFormSubmitted, WebNavigationTypeFormResubmitted. - [listener ignore]; - } - } -} - -/** - * Manage contextual menu in helpWebView - * Ignore "Reload", "Open Link", "Open Link in new Window", "Download link" etc. - */ -- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems -{ - - NSMutableArray *webViewMenuItems = [[defaultMenuItems mutableCopy] autorelease]; - - if (webViewMenuItems) - { - // Remove all needless default menu items - NSEnumerator *itemEnumerator = [defaultMenuItems objectEnumerator]; - NSMenuItem *menuItem = nil; - - while ((menuItem = [itemEnumerator nextObject])) - { - NSInteger tag = [menuItem tag]; - - switch (tag) - { - case 2000: // WebMenuItemTagOpenLink - case WebMenuItemTagOpenLinkInNewWindow: - case WebMenuItemTagDownloadLinkToDisk: - case WebMenuItemTagOpenImageInNewWindow: - case WebMenuItemTagDownloadImageToDisk: - case WebMenuItemTagCopyImageToClipboard: - case WebMenuItemTagOpenFrameInNewWindow: - case WebMenuItemTagStop: - case WebMenuItemTagReload: - case WebMenuItemTagCut: - case WebMenuItemTagPaste: - case WebMenuItemTagSpellingGuess: - case WebMenuItemTagNoGuessesFound: - case WebMenuItemTagIgnoreSpelling: - case WebMenuItemTagLearnSpelling: - case WebMenuItemTagOther: - case WebMenuItemTagOpenWithDefaultApplication: - [webViewMenuItems removeObjectIdenticalTo: menuItem]; - break; - } - } - } - - // Add two menu items for a selection if no link is given - if(webViewMenuItems - && [[element objectForKey:@"WebElementIsSelected"] boolValue] - && ![[element objectForKey:@"WebElementLinkIsLive"] boolValue]) - { - - NSMenuItem *searchInMySQL; - NSMenuItem *searchInMySQLonline; - - [webViewMenuItems insertObject:[NSMenuItem separatorItem] atIndex:0]; - - searchInMySQLonline = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Search in MySQL Documentation", @"Search in MySQL Documentation") action:@selector(searchInDocForWebViewSelection:) keyEquivalent:@""]; - [searchInMySQLonline setEnabled:YES]; - [searchInMySQLonline setTarget:self]; - [webViewMenuItems insertObject:searchInMySQLonline atIndex:0]; - [searchInMySQLonline release]; - - searchInMySQL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Search in MySQL Help", @"Search in MySQL Help") action:@selector(showHelpForWebViewSelection:) keyEquivalent:@""]; - [searchInMySQL setEnabled:YES]; - [searchInMySQL setTarget:self]; - [webViewMenuItems insertObject:searchInMySQL atIndex:0]; - [searchInMySQL release]; - - } - - return webViewMenuItems; + [[tableDocumentInstance helpViewerClient] showHelpFor:searchString addToHistory:YES calledByAutoHelp:YES]; } /** * Detect when the help window is closed (manually) and disable autohelp to ensure it * isn't reopened on keypresses. */ -- (BOOL)windowShouldClose:(id)sender +- (void)helpWindowClosedByUser:(NSNotification *)notification { - if (sender == helpWebViewWindow) { - [prefs setBool:NO forKey:SPCustomQueryUpdateAutoHelp]; - [prefs synchronize]; - [autohelpMenuItem setState:NSOffState]; - [textView setAutohelp:NO]; - } + if ([notification object] != [tableDocumentInstance helpViewerClient]) return; - return YES; + //TODO: this doesn't belong in the document context, since multiple open documents can become out of sync through this + [prefs setBool:NO forKey:SPCustomQueryUpdateAutoHelp]; + [prefs synchronize]; + [autohelpMenuItem setState:NSOffState]; + [textView setAutohelp:NO]; } #endif @@ -3749,26 +3272,6 @@ selectionIndexToRestore = nil; selectionViewportToRestore = NSZeroRect; -#ifndef SP_CODA - // init helpHTMLTemplate - NSError *error; - - helpHTMLTemplate = [[NSString alloc] - initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:SPHTMLHelpTemplate ofType:@"html"] - encoding:NSUTF8StringEncoding - error:&error]; - - // an error occurred while reading - if (helpHTMLTemplate == nil) { - NSLog(@"%@", [NSString stringWithFormat:@"Error reading “%@.html”!
%@", SPHTMLHelpTemplate, [error localizedFailureReason]]); - NSBeep(); - } - - // init search history - [helpWebView setMaintainsBackForwardList:YES]; - [[helpWebView backForwardList] setCapacity:20]; -#endif - // init tableView's data source resultData = [[SPDataStorage alloc] init]; editedRow = -1; @@ -4003,6 +3506,10 @@ selector:@selector(historyItemsHaveBeenUpdated:) name:SPHistoryItemsHaveBeenUpdatedNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(helpWindowClosedByUser:) + name:SPUserClosedHelpViewerNotification + object:[tableDocumentInstance helpViewerClient]]; #ifndef SP_CODA [prefs addObserver:self forKeyPath:SPGlobalResultTableFont options:NSKeyValueObservingOptionNew context:NULL]; @@ -4088,10 +3595,6 @@ if(fieldEditor) SPClear(fieldEditor); -#ifndef SP_CODA - if (helpHTMLTemplate) SPClear(helpHTMLTemplate); -#endif - if (mySQLversion) SPClear(mySQLversion); if (sortField) SPClear(sortField); if (cqColumnDefinition) SPClear(cqColumnDefinition); if (selectionIndexToRestore) SPClear(selectionIndexToRestore); diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index 20fb34d1..ceaca039 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -60,6 +60,7 @@ @class SPExtendedTableInfo; @class SPTableTriggers; @class SPTableRelations; +@class SPHelpViewerClient; #import "SPDatabaseContentViewDelegate.h" #import "SPConnectionControllerDelegateProtocol.h" @@ -92,6 +93,7 @@ IBOutlet id spHistoryControllerInstance; IBOutlet id exportControllerInstance; #endif + IBOutlet SPHelpViewerClient *helpViewerClientInstance; IBOutlet id statusTableAccessoryView; IBOutlet id statusTableView; @@ -325,6 +327,8 @@ @property (readonly) SPDatabaseStructure *databaseStructureRetrieval; @property (readonly) int64_t instanceId; +- (SPHelpViewerClient *)helpViewerClient; + #ifndef SP_CODA /* method decls */ - (BOOL)isUntitled; #endif diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 4bdd0aad..4909282c 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -48,7 +48,6 @@ #import "SPSQLParser.h" #import "SPTableData.h" #import "SPDatabaseData.h" -#import "SPDatabaseStructure.h" #import "SPExtendedTableInfo.h" #import "SPHistoryController.h" #import "SPPreferenceController.h" @@ -85,6 +84,8 @@ #import "ICUTemplateMatcher.h" #import "SPFavoritesOutlineView.h" #import "SPSSHTunnel.h" +#import "SPHelpViewerClient.h" +#import "SPHelpViewerController.h" #import @@ -511,6 +512,8 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; // Set the custom query editor's MySQL version [customQueryInstance setMySQLversion:mySQLVersion]; + [helpViewerClientInstance setConnection:mySQLConnection]; + #ifndef SP_CODA [self updateWindowTitle:self]; @@ -2661,6 +2664,11 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; } } +- (SPHelpViewerClient *)helpViewerClient +{ + return helpViewerClientInstance; +} + /** * Is current document Untitled? */ @@ -3602,8 +3610,8 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; */ - (IBAction)showMySQLHelp:(id)sender { - [customQueryInstance showHelpFor:SP_HELP_TOC_SEARCH_STRING addToHistory:YES calledByAutoHelp:NO]; - [[customQueryInstance helpWebViewWindow] makeKeyWindow]; + [helpViewerClientInstance showHelpFor:SPHelpViewerSearchTOC addToHistory:YES calledByAutoHelp:NO]; + [[helpViewerClientInstance helpWebViewWindow] makeKeyWindow]; } #endif diff --git a/Source/SPHelpViewerClient.h b/Source/SPHelpViewerClient.h new file mode 100644 index 00000000..b169e99f --- /dev/null +++ b/Source/SPHelpViewerClient.h @@ -0,0 +1,66 @@ +// +// SPHelpViewerClient.h +// sequel-pro +// +// Created by Max Lohrmann on 25.05.18. +// Copyright (c) 2018 Max Lohrmann. All rights reserved. +// Parts relocated from existing files. Previous copyright applies. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// More info at + +@class SPHelpViewerController; +@class SPMySQLConnection; +@class MGTemplateEngine; + +/** + * This is the client side of the Help Viewer window, i.e. this class + * can be instantiated from within an xib file as a custom object. + * + * It also contains the logic to look up the help in the mysql database + * using the mySQLConnection (which does not belong into the Help Viewer's + * window controller). + * + * Notifications posted: + * * SPUserClosedHelpViewerNotification + * When the user triggered closing the help viewer window + */ +@interface SPHelpViewerClient : NSObject +{ + SPHelpViewerController *controller; + + NSString *helpHTMLTemplate; + SPMySQLConnection *mySQLConnection; + + MGTemplateEngine *engine; +} + +- (void)setConnection:(SPMySQLConnection *)theConnection; + +- (NSWindow *)helpWebViewWindow; + +- (void)showHelpFor:(NSString *)aString addToHistory:(BOOL)addToHistory calledByAutoHelp:(BOOL)autoHelp; + +// this is not bound in Interface Builder, but used by the SPTextView context menu +- (IBAction)showHelpForCurrentWord:(id)sender; +@end diff --git a/Source/SPHelpViewerClient.m b/Source/SPHelpViewerClient.m new file mode 100644 index 00000000..54d8633d --- /dev/null +++ b/Source/SPHelpViewerClient.m @@ -0,0 +1,262 @@ +// +// SPHelpViewerClient.m +// sequel-pro +// +// Created by Max Lohrmann on 25.05.18. +// Copyright (c) 2018 Max Lohrmann. All rights reserved. +// Parts relocated from existing files. Previous copyright applies. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// More info at + +#import "SPHelpViewerClient.h" +#import "SPHelpViewerController.h" +#import +#import "RegexKitLite.h" +#import "MGTemplateEngine.h" +#import "ICUTemplateMatcher.h" + +@interface SPHelpViewerClient () + ++ (NSString *)linkToHelpTopic:(NSString *)aTopic; + +- (void)helpViewerClosed:(NSNotification *)notification; + +@end + +@implementation SPHelpViewerClient + +- (instancetype)init +{ + if (self = [super init]) { + controller = [[SPHelpViewerController alloc] init]; + [controller setDataSource:self]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(helpViewerClosed:) name:SPUserClosedHelpViewerNotification object:controller]; + + // init helpHTMLTemplate + NSError *error; + + helpHTMLTemplate = [[NSString alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:SPHTMLHelpTemplate ofType:@"html"] + encoding:NSUTF8StringEncoding + error:&error]; + + // Set up template engine with your chosen matcher + engine = [[MGTemplateEngine alloc] init]; + [engine setMatcher:[ICUTemplateMatcher matcherWithTemplateEngine:engine]]; + + // an error occurred while reading + if (helpHTMLTemplate == nil) { + helpHTMLTemplate = [@"{{body}}" copy]; //fallback + NSLog(@"%@", [NSString stringWithFormat:@"Error reading “%@.html”!
%@", SPHTMLHelpTemplate, [error localizedFailureReason]]); + NSBeep(); + } + } + return self; +} + +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [controller setDataSource:nil]; // we are the (unretained) datasource, but the controller may outlive us (if retained by other objects) + [controller close]; // hide the window if it is still visible (can't update anymore without delegate anyway) + + mySQLConnection = nil; + SPClear(controller); + SPClear(helpHTMLTemplate); + SPClear(engine); + [super dealloc]; +} + +- (void)helpViewerClosed:(NSNotification *)notification +{ + //we'll just proxy that notification because outsiders can't/shouldn't access the controller + [[NSNotificationCenter defaultCenter] postNotificationName:SPUserClosedHelpViewerNotification object:self]; +} + +- (void)openOnlineHelpForTopic:(NSString *)searchString +{ + NSString *version = nil; + if(![mySQLConnection serverVersionIsGreaterThanOrEqualTo:4 minorVersion:1 releaseVersion:0]) + version = @"4.1"; + else + version = [NSString stringWithFormat:@"%u.%u",(unsigned int)[mySQLConnection serverMajorVersion], (unsigned int)[mySQLConnection serverMinorVersion]]; + + NSString *url = [[NSString stringWithFormat: + SPMySQLSearchURL, + version, + NSLocalizedString(@"en", @"MySQL search language code - eg in http://search.mysql.com/search?q=select&site=refman-50&lr=lang_en"), + searchString] + stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]; + + if([url length]) [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]]; +} + +- (NSString *)HTMLHelpContentsForSearchString:(NSString *)searchString autoHelp:(BOOL)autoHelp +{ + if(![searchString length]) return @""; + + NSMutableString *theTitle = [NSMutableString stringWithFormat:NSLocalizedString(@"Version %@", @"Mysql Help Viewer : window title : mysql server version"),[mySQLConnection serverVersionString]]; + NSMutableString *theHelp = [NSMutableString string]; + + // Don't escape % when being used as a wildcard, but escape it when it's being used by itself. + if ([searchString isEqualToString:@"%"]) searchString = @"\\%"; + + // search via: HELP 'searchString' + SPMySQLResult *theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"HELP %@", [searchString tickQuotedString]]]; + if ([mySQLConnection queryErrored]) { + [theTitle setString:NSLocalizedString(@"Error", @"Mysql Help Viewer : window title : query error")]; + NSString *errMsg = [NSString stringWithFormat:@"ERROR %lu (%@): %@", (unsigned long)[mySQLConnection lastErrorID], [mySQLConnection lastSqlstate], [mySQLConnection lastErrorMessage]]; + [theHelp appendFormat:@"%@:

%@

", NSLocalizedString(@"MySQL Help Query Failed", @"Mysql Help Viewer : title of error message"), errMsg]; + goto generate_help; + } + + // nothing found? + if(![theResult numberOfRows]) { + // try to search via: HELP 'searchString%' + theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"HELP %@", [[searchString stringByAppendingString:@"%"] tickQuotedString]]]; + + // really nothing found? + if(![theResult numberOfRows]) { + [theTitle appendFormat:@": %@", NSLocalizedString(@"No Results", @"Mysql Help Viewer : window title : nothing found")]; + [theHelp appendFormat:@"%@", NSLocalizedString(@"No results found.", @"Mysql Help Viewer : Search : No results")]; + goto generate_help; + } + } + + // Ensure rows are returned as strings to prevent data problems with older 4.1 servers + [theResult setReturnDataAsStrings:YES]; + + NSDictionary *tableDetails = [[NSDictionary alloc] initWithDictionary:[theResult getRowAsDictionary]]; + + if ([tableDetails objectForKey:@"description"]) { // one single help topic found + if ([tableDetails objectForKey:@"name"]) { + [theTitle appendFormat:@": %@", [tableDetails objectForKey:@"name"]]; + [theHelp appendString:@"

"]; + [theHelp appendString:[tableDetails objectForKey:@"name"]]; + [theHelp appendString:@"

"]; + } + if ([tableDetails objectForKey:@"description"]) { + NSMutableString *desc = [NSMutableString string]; + NSError *err1 = NULL; + NSString *aUrl; + + [desc setString:[tableDetails objectForKey:@"description"]]; + + //[desc replaceOccurrencesOfString:[searchString uppercaseString] withString:[NSString stringWithFormat:@"%@", [searchString uppercaseString]] options:NSLiteralSearch range:NSMakeRange(0,[desc length])]; + + // detect and generate http links + NSRange aRange = NSMakeRange(0,0); + NSInteger safeCnt = 0; // safety counter - not more than 200 loops allowed + while(1) { + aRange = [desc rangeOfRegex:@"\\s((https?|ftp|file)://.*?html)" options:RKLNoOptions inRange:NSMakeRange(NSMaxRange(aRange), [desc length]-aRange.location-aRange.length) capture:1 error:&err1]; + if(aRange.location != NSNotFound) { + aUrl = [desc substringWithRange:aRange]; + [desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"%@", aUrl, aUrl]]; + } + else { + break; + } + safeCnt++; + if(safeCnt > 200) break; + } + + // Detect and generate cross-links. First, handle the old-style [HELP ...] text. + [desc replaceOccurrencesOfRegex:@"(\\[HELP ([^\\]]*?)\\]" withString:[[self class] linkToHelpTopic:@"$1"]]; + + // Handle "see [...]" and "in [...]"-style 5.x links. + //look-behind won't work here because of the \s+ + [desc replaceOccurrencesOfRegex:@"(See|see|In|in|and)\\s+\\[(?:HELP\\s+)?([^\\]]*?)\\]" withString:[NSString stringWithFormat:@"$1 %@",[[self class] linkToHelpTopic:@"$2"]]]; + + [theHelp appendFormat:@"
%@
", desc]; + } + // are examples available? + if([tableDetails objectForKey:@"example"]){ + NSString *examples = [[[tableDetails objectForKey:@"example"] copy] autorelease]; + if([examples length]) [theHelp appendFormat:@"
%1$@
%2$@
",NSLocalizedString(@"Example:",@"Mysql Help Viewer : Help Topic: Example section title"), examples]; + } + } + else { // list all found topics + // check if HELP 'contents' is called + if(![searchString isEqualToString:SPHelpViewerSearchTOC]) { + [theTitle appendString:@": "]; + [theTitle appendFormat:NSLocalizedString(@"Multiple Results for “%@”", @"Mysql Help Viewer : window title : multiple topics found"), searchString]; + [theHelp appendFormat:@"
%@
", [NSString stringWithFormat:NSLocalizedString(@"Help topics for “%@”", @"MySQL Help Viewer : Results list : Page title"), searchString]]; + } + else { + [theTitle appendFormat:@": %@", NSLocalizedString(@"Table of Contents", @"Mysql Help Viewer : window title : TOC")]; + [theHelp appendFormat:@"
%@:
", NSLocalizedString(@"MySQL Help – Categories", @"mysql help categories")]; + } + + // iterate through all found rows and print them as HTML ul/li list + [theHelp appendString:@"
    "]; + [theResult setDefaultRowReturnType:SPMySQLResultRowAsArray]; + for (NSArray *eachRow in theResult) { + NSString *topic = [eachRow objectAtIndex:[eachRow count]-2]; + [theHelp appendFormat:@"
  • %@
  • ",[[self class] linkToHelpTopic:topic]]; + } + [theHelp appendString:@"
"]; + } + + [tableDetails release]; + +generate_help: + return [engine processTemplate:helpHTMLTemplate withVariables:@{ + @"title": theTitle, + @"body": theHelp, + }]; +} + ++ (NSString *)linkToHelpTopic:(NSString *)aTopic +{ + NSString *linkTitle = [NSString stringWithFormat:NSLocalizedString(@"Show MySQL help for “%@”", @"MySQL Help Viewer : Results list : Link tooltip"),aTopic]; + return [NSString stringWithFormat:@"%1$@", aTopic, linkTitle]; +} + +- (void)setConnection:(SPMySQLConnection *)theConnection +{ + mySQLConnection = theConnection; +} + +/** + * Return the Help window. + */ +- (NSWindow *)helpWebViewWindow +{ + return [controller window]; +} + +- (void)showHelpFor:(NSString *)aString addToHistory:(BOOL)addToHistory calledByAutoHelp:(BOOL)autoHelp +{ + [controller showHelpFor:aString addToHistory:addToHistory calledByAutoHelp:autoHelp]; +} + +/** + * Show the data for "HELP 'currentWord'" + */ +- (IBAction)showHelpForCurrentWord:(id)sender +{ + NSString *searchString = [[sender string] substringWithRange:[sender getRangeForCurrentWord]]; + [controller showHelpFor:searchString addToHistory:YES calledByAutoHelp:NO]; +} + +@end diff --git a/Source/SPHelpViewerController.h b/Source/SPHelpViewerController.h new file mode 100644 index 00000000..c4de0d54 --- /dev/null +++ b/Source/SPHelpViewerController.h @@ -0,0 +1,99 @@ +// +// SPHelpViewerController.h +// sequel-pro +// +// Created by Max Lohrmann on 21.05.18. +// Copyright (c) 2018 Max Lohrmann. All rights reserved. +// Parts relocated from existing files. Previous copyright applies. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// More info at + +@class WebView; + +//private +typedef NS_ENUM(NSUInteger, HelpTarget) { + HelpTargetMySQL = 0, + HelpTargetPage = 1, + HelpTargetWeb = 2, +}; + +NSString * const SPHelpViewerSearchTOC; + +/** + * This notification is posted by the SPHelpViewerController when the user + * triggered closing the help viewer window (or by -performClose:). + * The window is not guaranteed to be off screen already, when the notification is sent. + * + * It will NOT be sent when the window was closed or hidden by code (including app termination). + */ +NSString * const SPUserClosedHelpViewerNotification; + +@protocol SPHelpViewerDataSource + +@required +/** + * When called with a search string this method should open the user's default browser + * with an URL to the MySQL online manual for the page that explains the search string. + */ +- (void)openOnlineHelpForTopic:(NSString *)searchString; + +/** + * This method is called by the SPHelpViewerController when it wants to receive the HTML + * page to display in response to a search string. + * + * The implementation has to handle the magic search string SPHelpViewerSearchTOC to + * return a table of contents document. + */ +- (NSString *)HTMLHelpContentsForSearchString:(NSString *)searchString autoHelp:(BOOL)autoHelp; + +@end + +/** + * This is the window controller class for the MySQL Help Viewer panel. + * + * See SPHelpViewerClient for the class that provides data for this controller and which + * can be instantiated from within an XIB. + * + * - Do NOT instantiate this class from within an XIB. + * - None of the methods in this class are thread-safe - always use the UI thread! + */ +@interface SPHelpViewerController : NSWindowController +{ + IBOutlet WebView *helpWebView; + + IBOutlet NSSearchField *helpSearchField; + IBOutlet NSSearchFieldCell *helpSearchFieldCell; + IBOutlet NSSegmentedControl *helpNavigator; + IBOutlet NSSegmentedControl *helpTargetSelector; + + HelpTarget helpTarget; + + id dataSource; +} + +@property (assign, nonatomic) id dataSource; + +- (void)showHelpFor:(NSString *)aString addToHistory:(BOOL)addToHistory calledByAutoHelp:(BOOL)autoHelp; + +@end diff --git a/Source/SPHelpViewerController.m b/Source/SPHelpViewerController.m new file mode 100644 index 00000000..a2c13000 --- /dev/null +++ b/Source/SPHelpViewerController.m @@ -0,0 +1,415 @@ +// +// SPHelpViewerController.m +// sequel-pro +// +// Created by Max Lohrmann on 21.05.18. +// Copyright (c) 2018 Max Lohrmann. All rights reserved. +// Parts relocated from existing files. Previous copyright applies. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// More info at + +#import "SPHelpViewerController.h" + +#import + +NSString * const SPHelpViewerSearchTOC = @"contents"; + +NSString * const SPUserClosedHelpViewerNotification = @"SPUserClosedHelpViewer"; + +typedef NS_ENUM(NSInteger, HelpNavButton) { + HelpNavButtonGoBack = 0, + HelpNavButtonShowTOC = 1, + HelpNavButtonGoForward = 2, +}; + +static void *HelpViewerControllerKVOContext = &HelpViewerControllerKVOContext; + +@interface SPHelpViewerController () +- (IBAction)showHelpForSearchString:(id)sender; +- (IBAction)helpSegmentDispatcher:(id)sender; +- (IBAction)helpSearchFindNextInPage:(id)sender; +- (IBAction)helpSearchFindPreviousInPage:(id)sender; +- (IBAction)helpTargetDispatcher:(id)sender; +- (IBAction)helpSelectHelpTargetMySQL:(id)sender; +- (IBAction)helpSelectHelpTargetPage:(id)sender; +- (IBAction)helpSelectHelpTargetWeb:(id)sender; + +- (IBAction)showHelpForWebViewSelection:(id)sender; +- (IBAction)searchInDocForWebViewSelection:(id)sender; +- (void)helpTargetValidation; +- (void)updateWindowTitle; +@end + +#pragma mark - + +@implementation SPHelpViewerController + +@synthesize dataSource = dataSource; + +- (instancetype)init +{ + if ((self = [super initWithWindowNibName:@"HelpViewer"])) { + //force window to be loaded for simplicity + [self window]; + } + return self; +} + +- (void)dealloc +{ + [helpWebView removeObserver:self forKeyPath:@"mainFrameTitle"]; //TODO: update to ...context: variant after 10.6 + [super dealloc]; +} + +- (void)windowDidLoad +{ + // init search history + [helpWebView setMaintainsBackForwardList:YES]; + [[helpWebView backForwardList] setCapacity:20]; + + [self updateWindowTitle]; + + [helpWebView addObserver:self forKeyPath:@"mainFrameTitle" options:0 context:HelpViewerControllerKVOContext]; +} + +- (void)observeValueForKeyPath:(nullable NSString *)keyPath ofObject:(nullable id)object change:(nullable NSDictionary *)change context:(nullable void *)context +{ + if(context == HelpViewerControllerKVOContext) { + if([@"mainFrameTitle" isEqualToString:keyPath] && object == helpWebView) { + [self updateWindowTitle]; + } + } + else { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } +} + +- (void)updateWindowTitle +{ + NSString *title = NSLocalizedString(@"MySQL Help", @"mysql help"); + + NSString *webTitle = [helpWebView mainFrameTitle]; + if([webTitle length]) title = [title stringByAppendingFormat:@" (%@)", webTitle]; + + [[self window] setTitle:title]; +} + +#pragma mark - +#pragma mark MySQL Help + +/** + * Show the data for "HELP 'searchString'". + */ +- (void)showHelpFor:(NSString *)searchString addToHistory:(BOOL)addToHistory calledByAutoHelp:(BOOL)autoHelp +{ + // If there's no search string, ignore if called by autohelp, show the index otherwise + if (![searchString length]) { + if (autoHelp) return; + searchString = SPHelpViewerSearchTOC; + } + + NSString *helpString = [dataSource HTMLHelpContentsForSearchString:searchString autoHelp:autoHelp]; + + // init the Help window if not visible + if(![[self window] isVisible]) { + // init goback/forward buttons + if([[helpWebView backForwardList] backListCount] < 1) { + [helpNavigator setEnabled:NO forSegment:HelpNavButtonGoBack]; + [helpNavigator setEnabled:NO forSegment:HelpNavButtonGoForward]; + } + else { + [helpNavigator setEnabled:([[helpWebView backForwardList] backListCount] != 0) forSegment:HelpNavButtonGoBack]; + [helpNavigator setEnabled:([[helpWebView backForwardList] forwardListCount] != 0) forSegment:HelpNavButtonGoForward]; + } + + // set default to search in MySQL help + helpTarget = HelpTargetMySQL; + [helpTargetSelector setSelectedSegment:HelpTargetMySQL]; + [self helpTargetValidation]; + + // show Help window + [[self window] orderFront:helpWebView]; + } + + if(![helpString length]) return; + + // add searchString to history list + if(addToHistory) { + WebHistoryItem *aWebHistoryItem = [[WebHistoryItem alloc] initWithURLString:[NSString stringWithFormat:@"applewebdata://%@", searchString] title:searchString lastVisitedTimeInterval:[[NSDate date] timeIntervalSinceDate:[NSDate distantFuture]]]; + [[helpWebView backForwardList] addItem:aWebHistoryItem]; + [aWebHistoryItem release]; + } + + // validate goback/forward buttons + [helpNavigator setEnabled:([[helpWebView backForwardList] backListCount] != 0) forSegment:HelpNavButtonGoBack]; + [helpNavigator setEnabled:([[helpWebView backForwardList] forwardListCount] != 0) forSegment:HelpNavButtonGoForward]; + + // load HTML formatted help into the webview + [[helpWebView mainFrame] loadHTMLString:helpString baseURL:nil]; +} + +/** + * Show the data for "HELP 'search word'" according to helpTarget + */ +- (IBAction)showHelpForSearchString:(id)sender +{ + NSString *searchString = [[helpSearchField stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + switch(helpTarget) { + case HelpTargetPage: + if(![helpWebView searchFor:searchString direction:YES caseSensitive:NO wrap:YES]) { + if([searchString length]) NSBeep(); + } + break; + case HelpTargetWeb: + if(![searchString length]) break; + [dataSource openOnlineHelpForTopic:searchString]; + break; + case HelpTargetMySQL: + [self showHelpFor:searchString addToHistory:YES calledByAutoHelp:NO]; + break; + } +} + +/** + * Show the Help for the selected text in the webview + */ +- (IBAction)showHelpForWebViewSelection:(id)sender +{ + [self showHelpFor:[[helpWebView selectedDOMRange] text] addToHistory:YES calledByAutoHelp:NO]; +} + +/** + * Show MySQL's online documentation for the selected text in the webview + */ +- (IBAction)searchInDocForWebViewSelection:(id)sender +{ + NSString *searchString = [[[helpWebView selectedDOMRange] text] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + if(![searchString length]) { + NSBeep(); + return; + } + [dataSource openOnlineHelpForTopic:searchString]; +} + +/** + * Find Next/Previous in current page + */ +- (IBAction)helpSearchFindNextInPage:(id)sender +{ + if(helpTarget == HelpTargetPage) { + if(![helpWebView searchFor:[[helpSearchField stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] direction:YES caseSensitive:NO wrap:YES]) NSBeep(); + } +} + +- (IBAction)helpSearchFindPreviousInPage:(id)sender +{ + if(helpTarget == HelpTargetPage) { + if(![helpWebView searchFor:[[helpSearchField stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] direction:NO caseSensitive:NO wrap:YES]) NSBeep(); + } +} + +/** + * Navigation for back/TOC/forward + */ +- (IBAction)helpSegmentDispatcher:(id)sender +{ + switch((HelpNavButton)[helpNavigator selectedSegment]) { + case HelpNavButtonGoBack: + [helpWebView goBack]; + break; + case HelpNavButtonShowTOC: + [self showHelpFor:SPHelpViewerSearchTOC addToHistory:YES calledByAutoHelp:NO]; + break; + case HelpNavButtonGoForward: + [helpWebView goForward]; + break; + } + + // validate goback and goforward buttons according history + [helpNavigator setEnabled:([[helpWebView backForwardList] backListCount] != 0) forSegment:HelpNavButtonGoBack]; + [helpNavigator setEnabled:([[helpWebView backForwardList] forwardListCount] != 0) forSegment:HelpNavButtonGoForward]; +} + +/** + * Set helpTarget according user choice via mouse and keyboard short-cuts. + */ +- (IBAction)helpSelectHelpTargetMySQL:(id)sender +{ + helpTarget = HelpTargetMySQL; + [helpTargetSelector setSelectedSegment:HelpTargetMySQL]; + [self helpTargetValidation]; +} + +- (IBAction)helpSelectHelpTargetPage:(id)sender +{ + helpTarget = HelpTargetPage; + [helpTargetSelector setSelectedSegment:HelpTargetPage]; + [self helpTargetValidation]; +} + +- (IBAction)helpSelectHelpTargetWeb:(id)sender +{ + helpTarget = HelpTargetWeb; + [helpTargetSelector setSelectedSegment:HelpTargetWeb]; + [self helpTargetValidation]; +} + +- (IBAction)helpTargetDispatcher:(id)sender +{ + helpTarget = (HelpTarget)[helpTargetSelector selectedSegment]; + [self helpTargetValidation]; +} + +/** + * Control the help search field behaviour. + */ +- (void)helpTargetValidation +{ + switch(helpTarget) { + case HelpTargetPage: + case HelpTargetWeb: + [helpSearchFieldCell setSendsWholeSearchString:YES]; + break; + case HelpTargetMySQL: + [helpSearchFieldCell setSendsWholeSearchString:NO]; + break; + } +} + +- (BOOL)windowShouldClose:(NSWindow *)sender +{ + // -windowShouldClose: is the only method that will ONLY be invoked when the user closes the window (or by -performClose:) + [[NSNotificationCenter defaultCenter] postNotificationName:SPUserClosedHelpViewerNotification object:self]; + return YES; +} + +#pragma mark - +#pragma mark WebView delegate methods + +/** + * Link detector: If user clicked at an http link open it in the default browser, + * otherwise search for it in the MySQL help. Additionally handle back/forward events from + * keyboard and context menu. + */ +- (void)webView:(WebView *)webView decidePolicyForNavigationAction:(NSDictionary *)actionInformation request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id)listener +{ + NSInteger navigationType = [[actionInformation objectForKey:WebActionNavigationTypeKey] integerValue]; + + if([[[request URL] scheme] isEqualToString:@"applewebdata"] && navigationType == WebNavigationTypeLinkClicked) { + [self showHelpFor:[[[request URL] path] lastPathComponent] addToHistory:YES calledByAutoHelp:NO]; + [listener ignore]; + } + else { + if (navigationType == WebNavigationTypeOther) { + // catch reload event + // if([[[actionInformation objectForKey:WebActionOriginalURLKey] absoluteString] isEqualToString:@"about:blank"]) + // [listener use]; + // else + [listener use]; + } + else if (navigationType == WebNavigationTypeLinkClicked) { + // show http in browser + [[NSWorkspace sharedWorkspace] openURL:[actionInformation objectForKey:WebActionOriginalURLKey]]; + [listener ignore]; + } + else if (navigationType == WebNavigationTypeBackForward) { + // catch back/forward events from contextual menu + [self showHelpFor:[[[[actionInformation objectForKey:WebActionOriginalURLKey] absoluteString] lastPathComponent] stringByReplacingPercentEscapesUsingEncoding:NSASCIIStringEncoding] addToHistory:NO calledByAutoHelp:NO]; + [listener ignore]; + } + else { + // Ignore WebNavigationTypeFormSubmitted, WebNavigationTypeFormResubmitted, WebNavigationTypeReload. + [listener ignore]; + } + } +} + +/** + * Manage contextual menu in helpWebView + * Ignore "Reload", "Open Link", "Open Link in new Window", "Download link" etc. + */ +- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems +{ + NSMutableArray *webViewMenuItems = [[defaultMenuItems mutableCopy] autorelease]; + + if (webViewMenuItems) { + // Remove all needless default menu items + NSEnumerator *itemEnumerator = [defaultMenuItems objectEnumerator]; + NSMenuItem *menuItem = nil; + + while ((menuItem = [itemEnumerator nextObject])) { + NSInteger tag = [menuItem tag]; + + switch (tag) { + case 2000: // WebMenuItemTagOpenLink + case WebMenuItemTagOpenLinkInNewWindow: + case WebMenuItemTagDownloadLinkToDisk: + case WebMenuItemTagOpenImageInNewWindow: + case WebMenuItemTagDownloadImageToDisk: + case WebMenuItemTagCopyImageToClipboard: + case WebMenuItemTagOpenFrameInNewWindow: + case WebMenuItemTagStop: + case WebMenuItemTagReload: + case WebMenuItemTagCut: + case WebMenuItemTagPaste: + case WebMenuItemTagSpellingGuess: + case WebMenuItemTagNoGuessesFound: + case WebMenuItemTagIgnoreSpelling: + case WebMenuItemTagLearnSpelling: + case WebMenuItemTagOther: + case WebMenuItemTagOpenWithDefaultApplication: + [webViewMenuItems removeObjectIdenticalTo: menuItem]; + break; + } + } + } + + // Add two menu items for a selection if no link is given + if(webViewMenuItems + && [[element objectForKey:@"WebElementIsSelected"] boolValue] + && ![[element objectForKey:@"WebElementLinkIsLive"] boolValue]) + { + + NSMenuItem *searchInMySQL; + NSMenuItem *searchInMySQLonline; + + [webViewMenuItems insertObject:[NSMenuItem separatorItem] atIndex:0]; + + searchInMySQLonline = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Search in MySQL Documentation", @"Search in MySQL Documentation") action:@selector(searchInDocForWebViewSelection:) keyEquivalent:@""]; + [searchInMySQLonline setEnabled:YES]; + [searchInMySQLonline setTarget:self]; + [webViewMenuItems insertObject:searchInMySQLonline atIndex:0]; + [searchInMySQLonline release]; + + searchInMySQL = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Search in MySQL Help", @"Search in MySQL Help") action:@selector(showHelpForWebViewSelection:) keyEquivalent:@""]; + [searchInMySQL setEnabled:YES]; + [searchInMySQL setTarget:self]; + [webViewMenuItems insertObject:searchInMySQL atIndex:0]; + [searchInMySQL release]; + } + + return webViewMenuItems; +} + +@end diff --git a/Source/SPTextView.m b/Source/SPTextView.m index de1ddc04..6b98217c 100644 --- a/Source/SPTextView.m +++ b/Source/SPTextView.m @@ -50,6 +50,7 @@ #import "SPCopyTable.h" #import "SPEditorTokens.h" #import "SPSyntaxParser.h" +#import "SPHelpViewerClient.h" #import @@ -1107,7 +1108,7 @@ retry: */ - (IBAction) showMySQLHelpForCurrentWord:(id)sender { - [customQueryInstance showHelpForCurrentWord:self]; + [[tableDocumentInstance helpViewerClient] showHelpForCurrentWord:self]; } #endif diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index 16a3957d..435e2b82 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -391,8 +391,10 @@ 58FEF57E0F3B4E9700518E8E /* SPTableData.m in Sources */ = {isa = PBXBuildFile; fileRef = 58FEF57D0F3B4E9700518E8E /* SPTableData.m */; }; 73F70A961E4E547500636550 /* SPJSONFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 73F70A951E4E547500636550 /* SPJSONFormatter.m */; }; 8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; }; + 9BE765682376A00C82FB93AA /* SPHelpViewerClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE764320CE8E86E8F63647B /* SPHelpViewerClient.m */; }; 9BE765EBBDFD2F121C13D274 /* SPFillView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE768F3989033CEDDC2027E /* SPFillView.m */; }; 9BE76F2886901784E4FD2321 /* SPFilterTableController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE76A3D5C9830E2F7738770 /* SPFilterTableController.m */; }; + 9BE76F2B943AFDBA6EDC52BE /* SPHelpViewerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE760B3C4586EA3B1A48600 /* SPHelpViewerController.m */; }; B51D6B9E114C310C0074704E /* toolbar-switch-to-table-triggers.png in Resources */ = {isa = PBXBuildFile; fileRef = B51D6B9D114C310C0074704E /* toolbar-switch-to-table-triggers.png */; }; B52460D70F8EF92300171639 /* SPArrayAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B52460D40F8EF92300171639 /* SPArrayAdditions.m */; }; B52460D80F8EF92300171639 /* SPTextViewAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B52460D60F8EF92300171639 /* SPTextViewAdditions.m */; }; @@ -418,6 +420,7 @@ BA6B044120A4FEDC00B012E1 /* button_filter_active.png in Resources */ = {isa = PBXBuildFile; fileRef = BA6B043F20A4FEDB00B012E1 /* button_filter_active.png */; }; BA6B044220A4FEDC00B012E1 /* button_filter.png in Resources */ = {isa = PBXBuildFile; fileRef = BA6B044020A4FEDC00B012E1 /* button_filter.png */; }; BAC6BAF920A0D22400247837 /* FilterTableWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = BAC6BAF720A0D22400247837 /* FilterTableWindow.xib */; }; + BAE25E0120B32BDA00DD9A40 /* HelpViewer.xib in Resources */ = {isa = PBXBuildFile; fileRef = BAE25DFF20B32BDA00DD9A40 /* HelpViewer.xib */; }; BC01BCCF104024BE006BDEE7 /* SPEncodingPopupAccessory.m in Sources */ = {isa = PBXBuildFile; fileRef = BC01BCCE104024BE006BDEE7 /* SPEncodingPopupAccessory.m */; }; BC05F1C5101241DF008A97F8 /* YRKSpinningProgressIndicator.m in Sources */ = {isa = PBXBuildFile; fileRef = BC05F1C4101241DF008A97F8 /* YRKSpinningProgressIndicator.m */; }; BC09D7DE12A786FB0030DB64 /* cancel-clicked-highlighted.png in Resources */ = {isa = PBXBuildFile; fileRef = BC09D7D812A786FB0030DB64 /* cancel-clicked-highlighted.png */; }; @@ -1134,8 +1137,12 @@ 73F70A941E4E547500636550 /* SPJSONFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPJSONFormatter.h; sourceTree = ""; }; 73F70A951E4E547500636550 /* SPJSONFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPJSONFormatter.m; sourceTree = ""; }; 8D15AC370486D014006FF6A4 /* Sequel Pro.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Sequel Pro.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 9BE760B3C4586EA3B1A48600 /* SPHelpViewerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPHelpViewerController.m; sourceTree = ""; }; + 9BE761AE45D4F6B9B90E67DE /* SPHelpViewerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPHelpViewerClient.h; sourceTree = ""; }; + 9BE764320CE8E86E8F63647B /* SPHelpViewerClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPHelpViewerClient.m; sourceTree = ""; }; 9BE768F3989033CEDDC2027E /* SPFillView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPFillView.m; sourceTree = ""; }; 9BE76A3D5C9830E2F7738770 /* SPFilterTableController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPFilterTableController.m; sourceTree = ""; }; + 9BE76C6E8377959C794385E5 /* SPHelpViewerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPHelpViewerController.h; sourceTree = ""; }; 9BE76CC0CCE3A4A74E3E8D5E /* SPFillView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPFillView.h; sourceTree = ""; }; 9BE76F9BF9BDA2921CDD05AF /* SPFilterTableController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPFilterTableController.h; sourceTree = ""; }; B51D6B9D114C310C0074704E /* toolbar-switch-to-table-triggers.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "toolbar-switch-to-table-triggers.png"; sourceTree = ""; }; @@ -1169,6 +1176,7 @@ BA6B043F20A4FEDB00B012E1 /* button_filter_active.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = button_filter_active.png; sourceTree = ""; }; BA6B044020A4FEDC00B012E1 /* button_filter.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = button_filter.png; sourceTree = ""; }; BAC6BAF820A0D22400247837 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/FilterTableWindow.xib; sourceTree = ""; }; + BAE25E0020B32BDA00DD9A40 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/HelpViewer.xib; sourceTree = ""; }; BC01BCCD104024BE006BDEE7 /* SPEncodingPopupAccessory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPEncodingPopupAccessory.h; sourceTree = ""; }; BC01BCCE104024BE006BDEE7 /* SPEncodingPopupAccessory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPEncodingPopupAccessory.m; sourceTree = ""; }; BC05F1C3101241DF008A97F8 /* YRKSpinningProgressIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YRKSpinningProgressIndicator.h; sourceTree = ""; }; @@ -1575,6 +1583,10 @@ 17846B9D170C95D800414499 /* Process List */, 9BE76A3D5C9830E2F7738770 /* SPFilterTableController.m */, 9BE76F9BF9BDA2921CDD05AF /* SPFilterTableController.h */, + 9BE760B3C4586EA3B1A48600 /* SPHelpViewerController.m */, + 9BE76C6E8377959C794385E5 /* SPHelpViewerController.h */, + 9BE764320CE8E86E8F63647B /* SPHelpViewerClient.m */, + 9BE761AE45D4F6B9B90E67DE /* SPHelpViewerClient.h */, ); name = "Subview Controllers"; sourceTree = ""; @@ -2183,6 +2195,7 @@ B58DA7390FF8BB9E00FDDACD /* SSHQuestionDialog.xib */, 4D90B7A0101E0D1500D116A1 /* UserManagerView.xib */, BAC6BAF720A0D22400247837 /* FilterTableWindow.xib */, + BAE25DFF20B32BDA00DD9A40 /* HelpViewer.xib */, ); path = Interfaces; sourceTree = ""; @@ -2988,6 +3001,7 @@ 582E942016835DD4003459FD /* button_edit_mode.png in Resources */, 582E942416835EA9003459FD /* button_edit.png in Resources */, 582E942616835FAE003459FD /* button_remove.png in Resources */, + BAE25E0120B32BDA00DD9A40 /* HelpViewer.xib in Resources */, 582E942B1683628C003459FD /* button_select_all.png in Resources */, 582E942C1683628C003459FD /* button_select_none.png in Resources */, 582E942E1683658A003459FD /* clearconsole.png in Resources */, @@ -3299,6 +3313,8 @@ 1A564F74237E2E4958CA593A /* SPPillAttachmentCell.m in Sources */, 9BE76F2886901784E4FD2321 /* SPFilterTableController.m in Sources */, 9BE765EBBDFD2F121C13D274 /* SPFillView.m in Sources */, + 9BE76F2B943AFDBA6EDC52BE /* SPHelpViewerController.m in Sources */, + 9BE765682376A00C82FB93AA /* SPHelpViewerClient.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3582,6 +3598,14 @@ name = FilterTableWindow.xib; sourceTree = ""; }; + BAE25DFF20B32BDA00DD9A40 /* HelpViewer.xib */ = { + isa = PBXVariantGroup; + children = ( + BAE25E0020B32BDA00DD9A40 /* English */, + ); + name = HelpViewer.xib; + sourceTree = ""; + }; BC30C00F111C98BD002701C9 /* DataMigrationDialog.xib */ = { isa = PBXVariantGroup; children = ( -- cgit v1.2.3 #n2946'>2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325