Permalink
Browse files

#2485: Make external links in help viewer more readable in dark mode.

  • Loading branch information...
stuconnolly committed Oct 3, 2018
1 parent 87ea3c0 commit 562eb1d47ed6efa2e55924387a1a3f827906b5c0
Showing with 40 additions and 18 deletions.
  1. +4 −0 Resources/Templates/SPMySQLHelpTemplate.html
  2. +36 −18 Source/SPHelpViewerClient.m
@@ -49,6 +49,10 @@
.dark .internallink {
color: rgb(65, 156, 255);
}
.dark a {
color: rgb(65, 156, 255);
}
</style>
<script type="text/javascript">
window.onThemeChange = function(theme) {
@@ -79,21 +79,11 @@ - (instancetype)init
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];
}
#pragma mark -
- (void)helpViewerClosed:(NSNotification *)notification
{
@@ -104,10 +94,14 @@ - (void)helpViewerClosed:(NSNotification *)notification
- (void)openOnlineHelpForTopic:(NSString *)searchString
{
NSString *version = nil;
if(![mySQLConnection serverVersionIsGreaterThanOrEqualTo:4 minorVersion:1 releaseVersion:0])
if (![mySQLConnection serverVersionIsGreaterThanOrEqualTo:4 minorVersion:1 releaseVersion:0])
{
version = @"4.1";
else
}
else {
version = [NSString stringWithFormat:@"%u.%u",(unsigned int)[mySQLConnection serverMajorVersion], (unsigned int)[mySQLConnection serverMinorVersion]];
}
NSString *url = [[NSString stringWithFormat:
SPMySQLSearchURL,
@@ -116,7 +110,9 @@ - (void)openOnlineHelpForTopic:(NSString *)searchString
searchString]
stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
if([url length]) [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
if ([url length]) {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
}
}
- (NSString *)HTMLHelpContentsForSearchString:(NSString *)searchString autoHelp:(BOOL)autoHelp
@@ -218,10 +214,14 @@ - (NSString *)HTMLHelpContentsForSearchString:(NSString *)searchString autoHelp:
// iterate through all found rows and print them as HTML ul/li list
[theHelp appendString:@"<ul>"];
[theResult setDefaultRowReturnType:SPMySQLResultRowAsArray];
for (NSArray *eachRow in theResult) {
NSString *topic = [eachRow objectAtIndex:[eachRow count]-2];
[theHelp appendFormat:@"<li>%@</li>",[[self class] linkToHelpTopic:topic]];
for (NSArray *eachRow in theResult)
{
NSString *topic = [eachRow objectAtIndex:[eachRow count] - 2];
[theHelp appendFormat:@"<li>%@</li>", [[self class] linkToHelpTopic:topic]];
}
[theHelp appendString:@"</ul>"];
}
@@ -280,4 +280,22 @@ - (IBAction)showHelpForCurrentWord:(id)sender
[controller showHelpFor:searchString addToHistory:YES calledByAutoHelp:NO];
}
#pragma mark -
- (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];
}
@end

0 comments on commit 562eb1d

Please sign in to comment.